1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| -module(table_manager).
| -compile(export_all).
|
| createSyncTables() ->
| {ok, DB} = esqlite3:open(database_name:getSyncDatabaseName()),
| ok = esqlite3:exec("CREATE TABLE IF NOT EXISTS 'cluster_info'(`table` text, cluster_id text PRIMARY KEY,cluster_name text,create_time text ,update_time text,create_by text,del_flag text );", DB),
| ok = esqlite3:exec("CREATE UNIQUE INDEX IF NOT EXISTS idx_cluster_info ON cluster_info (cluster_id);", DB),
| ok = esqlite3:exec("CREATE TABLE IF NOT EXISTS 'device_info'(`father_node` text, `table` text ,uuid text PRIMARY KEY, node_id text, device_id text, cluster_id text, create_time text, update_time text, create_by text, del_flag text );", DB),
| ok = esqlite3:exec("CREATE UNIQUE INDEX IF NOT EXISTS idx_device_info ON device_info (uuid);", DB),
| esqlite3:close(DB).
|
| createCacheTables() ->
| {ok, DB} = esqlite3:open(database_name:getCacheDatabaseName()),
| ok = esqlite3:exec("CREATE TABLE IF NOT EXISTS SqlCache (
| uuid TEXT PRIMARY KEY,
| func TEXT DEFAULT NULL,
| sql TEXT DEFAULT NULL,
| create_time TEXT,
| create_by TEXT
| );", DB),
| ok = esqlite3:exec("CREATE UNIQUE INDEX IF NOT EXISTS idx_sql_cache ON SqlCache (uuid);", DB),
| ok = esqlite3:exec("CREATE TABLE IF NOT EXISTS sql_cache_device (
| sql_cache_id TEXT ,
| receive_device_id TEXT,
| CONSTRAINT idx_sql_cache_device UNIQUE (sql_cache_id, receive_device_id));", DB),
| esqlite3:close(DB).
|
|