* Some work on message base tables. WIP, not functional
This commit is contained in:
parent
a1a4c09214
commit
8fecc779d1
|
@ -53,10 +53,10 @@ function createUserTables() {
|
||||||
);
|
);
|
||||||
|
|
||||||
dbs.user.run(
|
dbs.user.run(
|
||||||
'CREATE TABLE IF NOT EXISTS user_group (' +
|
'CREATE TABLE IF NOT EXISTS user_group (' +
|
||||||
' group_id INTEGER PRIMARY KEY,' +
|
' group_id INTEGER PRIMARY KEY,' +
|
||||||
' group_name VARCHAR NOT NULL,' +
|
' group_name VARCHAR NOT NULL,' +
|
||||||
' UNIQUE(group_name)' +
|
' UNIQUE(group_name)' +
|
||||||
');'
|
');'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -71,19 +71,35 @@ function createUserTables() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMessageBaseTables() {
|
function createMessageBaseTables() {
|
||||||
|
|
||||||
dbs.message.run(
|
dbs.message.run(
|
||||||
'CREATE TABLE IF NOT EXISTS message (' +
|
'CREATE TABLE IF NOT EXISTS message_area (' +
|
||||||
' message_id INTEGER PRIMARY KEY,' +
|
' area_id INTEGER PRIMARY KEY,' +
|
||||||
' area_id INTEGER NOT NULL,' +
|
' area_name VARCHAR NOT NULL,' +
|
||||||
' message_uuid VARCHAR(36) NOT NULL,' +
|
' UNIQUE(area_name)' +
|
||||||
' reply_to_id INTEGER,' +
|
');'
|
||||||
' to_user_name VARCHAR NOT NULL,' +
|
);
|
||||||
' from_user_name VARCHAR NOT NULL,' +
|
|
||||||
' subject,' + // FTS @ message_fts
|
dbs.message.run(
|
||||||
' message,' + // FTS @ message_fts
|
'CREATE TABLE IF NOT EXISTS message_area_group (' +
|
||||||
' modified_timestamp DATETIME NOT NULL,' +
|
' area_id INTEGER NOT NULL,' +
|
||||||
' UNIQUE(message_id, area_id),' +
|
' group_id INTEGER NOT NULL' + // FK @ user.sqlite::user_group::group_id
|
||||||
' UNIQUE(message_uuid)' +
|
');'
|
||||||
|
);
|
||||||
|
|
||||||
|
dbs.message.run(
|
||||||
|
'CREATE TABLE IF NOT EXISTS message (' +
|
||||||
|
' message_id INTEGER PRIMARY KEY,' +
|
||||||
|
' area_id INTEGER NOT NULL,' +
|
||||||
|
' message_uuid VARCHAR(36) NOT NULL,' +
|
||||||
|
' reply_to_message_id INTEGER,' +
|
||||||
|
' to_user_name VARCHAR NOT NULL,' +
|
||||||
|
' from_user_name VARCHAR NOT NULL,' +
|
||||||
|
' subject,' + // FTS @ message_fts
|
||||||
|
' message,' + // FTS @ message_fts
|
||||||
|
' modified_timestamp DATETIME NOT NULL,' +
|
||||||
|
' UNIQUE(message_uuid)' +
|
||||||
|
' FOREIGN KEY(area_id) REFERENCES message_area(area_id)' +
|
||||||
');'
|
');'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -96,19 +112,27 @@ function createMessageBaseTables() {
|
||||||
);
|
);
|
||||||
|
|
||||||
dbs.message.run(
|
dbs.message.run(
|
||||||
'CREATE TABLE IF NOT EXISTS message_meta (' +
|
'CREATE TABLE IF NOT EXISTS message_meta (' +
|
||||||
' message_id INTEGER NOT NULL,' +
|
' message_id INTEGER NOT NULL,' +
|
||||||
' meta_name VARCHAR NOT NULL,' +
|
' meta_name VARCHAR NOT NULL,' +
|
||||||
' meta_value VARCHAR NOT NULL,' +
|
' meta_value VARCHAR NOT NULL,' +
|
||||||
' UNIQUE(message_id, meta_name),' +
|
' UNIQUE(message_id, meta_name),' +
|
||||||
' FOREIGN KEY(message_id) REFERENCES message(message_id) ON DELETE CASCADE' +
|
' FOREIGN KEY(message_id) REFERENCES message(message_id)' +
|
||||||
');'
|
');'
|
||||||
);
|
);
|
||||||
|
|
||||||
dbs.message.run(
|
dbs.message.run(
|
||||||
'CREATE TABLE IF NOT EXISTS message_hash_tag (' +
|
'CREATE TABLE IF NOT EXISTS hash_tag (' +
|
||||||
' hash_tag VARCHAR NOT NULL,' +
|
' hash_tag_id INTEGER PRIMARY KEY,' +
|
||||||
' message_id INTEGER NOT NULL' +
|
' hash_tag_name VARCHAR NOT NULL,' +
|
||||||
|
' UNIQUE(hash_tag_name)' +
|
||||||
|
');'
|
||||||
|
);
|
||||||
|
|
||||||
|
dbs.message.run(
|
||||||
|
'CREATE TABLE IF NOT EXISTS message_hash_tag (' +
|
||||||
|
' hash_tag_id INTEGER NOT NULL,' +
|
||||||
|
' message_id INTEGER NOT NULL' +
|
||||||
');'
|
');'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue