Merge pull request #14 from 30x/SQLlite_tohave_schemas
SQLlite now have schemas
diff --git a/.gitignore b/.gitignore
index 5e9f67b..3825b7a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
cover.html
coverage.txt
+*.iml
+.idea
diff --git a/apidAnalytics_suite_test.go b/apidAnalytics_suite_test.go
index 46e2421..d2d97e6 100644
--- a/apidAnalytics_suite_test.go
+++ b/apidAnalytics_suite_test.go
@@ -41,11 +41,8 @@
Expect(err).NotTo(HaveOccurred())
initDb(db)
- // required config uapServerBase is not set, thus init should panic
- Expect(apid.InitializePlugins).To(Panic())
-
config.Set(uapServerBase, "http://localhost:9000") // dummy value
- Expect(apid.InitializePlugins).ToNot(Panic())
+ apid.InitializePlugins("")
// Analytics POST API
router := apid.API().Router()
@@ -109,7 +106,7 @@
func createTables(db apid.DB) {
_, err := db.Exec(`
- CREATE TABLE IF NOT EXISTS api_product (
+ CREATE TABLE IF NOT EXISTS kms_api_product (
id text,
tenant_id text,
name text,
@@ -128,7 +125,7 @@
updated_at int64,
updated_by text,
PRIMARY KEY (tenant_id, id));
- CREATE TABLE IF NOT EXISTS developer (
+ CREATE TABLE IF NOT EXISTS kms_developer (
id text,
tenant_id text,
username text,
@@ -146,7 +143,7 @@
updated_by text,
PRIMARY KEY (tenant_id, id)
);
- CREATE TABLE IF NOT EXISTS app (
+ CREATE TABLE IF NOT EXISTS kms_app (
id text,
tenant_id text,
name text,
@@ -165,7 +162,7 @@
_change_selector text,
PRIMARY KEY (tenant_id, id)
);
- CREATE TABLE IF NOT EXISTS app_credential_apiproduct_mapper (
+ CREATE TABLE IF NOT EXISTS kms_app_credential_apiproduct_mapper (
tenant_id text,
appcred_id text,
app_id text,
@@ -182,7 +179,7 @@
func createApidClusterTables(db apid.DB) {
_, err := db.Exec(`
- CREATE TABLE apid_cluster (
+ CREATE TABLE edgex_apid_cluster (
id text,
instance_id text,
name text,
@@ -197,7 +194,7 @@
lastSequence text,
PRIMARY KEY (id)
);
- CREATE TABLE data_scope (
+ CREATE TABLE edgex_data_scope (
id text,
apid_cluster_id text,
scope text,
@@ -220,7 +217,7 @@
txn, err := db.Begin()
Expect(err).ShouldNot(HaveOccurred())
- txn.Exec("INSERT INTO APP_CREDENTIAL_APIPRODUCT_MAPPER (tenant_id,"+
+ txn.Exec("INSERT INTO kms_app_credential_apiproduct_mapper (tenant_id,"+
" appcred_id, app_id, apiprdt_id, status, _change_selector) "+
"VALUES"+
"($1,$2,$3,$4,$5,$6)",
@@ -232,7 +229,7 @@
"12345",
)
- txn.Exec("INSERT INTO APP (id, tenant_id, name, developer_id) "+
+ txn.Exec("INSERT INTO kms_app (id, tenant_id, name, developer_id) "+
"VALUES"+
"($1,$2,$3,$4)",
"testappid",
@@ -241,7 +238,7 @@
"testdeveloperid",
)
- txn.Exec("INSERT INTO API_PRODUCT (id, tenant_id, name) "+
+ txn.Exec("INSERT INTO kms_api_product (id, tenant_id, name) "+
"VALUES"+
"($1,$2,$3)",
"testproductid",
@@ -249,7 +246,7 @@
"testproduct",
)
- txn.Exec("INSERT INTO DEVELOPER (id, tenant_id, username, email) "+
+ txn.Exec("INSERT INTO kms_developer (id, tenant_id, username, email) "+
"VALUES"+
"($1,$2,$3,$4)",
"testdeveloperid",
@@ -258,7 +255,7 @@
"testdeveloper@test.com",
)
- txn.Exec("INSERT INTO DATA_SCOPE (id, _change_selector, "+
+ txn.Exec("INSERT INTO edgex_data_scope (id, _change_selector, "+
"apid_cluster_id, scope, org, env) "+
"VALUES"+
"($1,$2,$3,$4,$5,$6)",
diff --git a/common_helper.go b/common_helper.go
index b3a9a5f..b8a2696 100644
--- a/common_helper.go
+++ b/common_helper.go
@@ -135,7 +135,7 @@
var org, env, tenantId string
db := getDB()
- error := db.QueryRow("SELECT env, org, scope FROM DATA_SCOPE"+
+ error := db.QueryRow("SELECT env, org, scope FROM edgex_data_scope"+
" where id = ?", scopeuuid).Scan(&env, &org, &tenantId)
switch {
@@ -165,10 +165,10 @@
db := getDB()
sSql := "SELECT ap.name, a.name, d.username, d.email " +
- "FROM APP_CREDENTIAL_APIPRODUCT_MAPPER as mp " +
- "INNER JOIN API_PRODUCT as ap ON ap.id = mp.apiprdt_id " +
- "INNER JOIN APP AS a ON a.id = mp.app_id " +
- "INNER JOIN DEVELOPER as d ON d.id = a.developer_id " +
+ "FROM kms_app_credential_apiproduct_mapper as mp " +
+ "INNER JOIN kms_api_product as ap ON ap.id = mp.apiprdt_id " +
+ "INNER JOIN kms_app AS a ON a.id = mp.app_id " +
+ "INNER JOIN kms_developer as d ON d.id = a.developer_id " +
"where mp.tenant_id = ? and mp.appcred_id = ?;"
error := db.QueryRow(sSql, tenantId, apiKey).
Scan(&apiProduct, &developerApp,
diff --git a/listener_test.go b/listener_test.go
index 6a027f5..b14fd9f 100644
--- a/listener_test.go
+++ b/listener_test.go
@@ -86,7 +86,7 @@
It("insert/delete event should add/remove to/from cache if usecaching is true", func() {
txn, err := getDB().Begin()
Expect(err).ShouldNot(HaveOccurred())
- txn.Exec("INSERT INTO DATA_SCOPE (id, _change_selector, apid_cluster_id, scope, org, env) "+
+ txn.Exec("INSERT INTO edgex_data_scope (id, _change_selector, apid_cluster_id, scope, org, env) "+
"VALUES"+
"($1,$2,$3,$4,$5,$6)",
"i2",
@@ -128,7 +128,7 @@
txn, err = getDB().Begin()
Expect(err).ShouldNot(HaveOccurred())
- txn.Exec("DELETE FROM DATA_SCOPE where id = 'i2'")
+ txn.Exec("DELETE FROM edgex_data_scope where id = 'i2'")
txn.Commit()
delete := common.ChangeList{