More complete SQL stuff for #102.

This commit is contained in:
martinrotter 2017-03-14 07:40:49 +01:00
parent e9a0b62e27
commit a4e2240e05
4 changed files with 44 additions and 0 deletions

View File

@ -113,5 +113,16 @@ CREATE TABLE IF NOT EXISTS Labels (
custom_id TEXT,
custom_hash TEXT,
FOREIGN KEY (account_id) REFERENCES Accounts (id)
);
-- !
DROP TABLE IF EXISTS LabelsInMessages;
-- !
CREATE TABLE IF NOT EXISTS LabelsInMessages (
id INTEGER AUTO_INCREMENT PRIMARY KEY,
message_custom_id TEXT NOT NULL,
label_custom_id TEXT NOT NULL,
account_id INTEGER NOT NULL,
FOREIGN KEY (account_id) REFERENCES Accounts (id)
);

View File

@ -108,5 +108,18 @@ CREATE TABLE IF NOT EXISTS Labels (
custom_id TEXT,
custom_hash TEXT,
FOREIGN KEY (account_id) REFERENCES Accounts (id)
);
-- !
DROP TABLE IF EXISTS LabelsInMessages;
-- !
CREATE TABLE IF NOT EXISTS LabelsInMessages (
id INTEGER PRIMARY KEY,
message_custom_id TEXT NOT NULL,
label_custom_id TEXT NOT NULL,
account_id INTEGER NOT NULL,
FOREIGN KEY (message_custom_id) REFERENCES Messages (custom_id),
FOREIGN KEY (label_custom_id) REFERENCES Labels (custom_id),
FOREIGN KEY (account_id) REFERENCES Accounts (id)
);

View File

@ -11,4 +11,13 @@ CREATE TABLE IF NOT EXISTS Labels (
FOREIGN KEY (account_id) REFERENCES Accounts (id)
);
-- !
CREATE TABLE IF NOT EXISTS LabelsInMessages (
id INTEGER AUTO_INCREMENT PRIMARY KEY,
message_custom_id TEXT NOT NULL,
label_custom_id TEXT NOT NULL,
account_id INTEGER NOT NULL,
FOREIGN KEY (account_id) REFERENCES Accounts (id)
);
-- !
UPDATE Information SET inf_value = '8' WHERE inf_key = 'schema_version';

View File

@ -11,4 +11,15 @@ CREATE TABLE IF NOT EXISTS Labels (
FOREIGN KEY (account_id) REFERENCES Accounts (id)
);
-- !
CREATE TABLE IF NOT EXISTS LabelsInMessages (
id INTEGER PRIMARY KEY,
message_custom_id TEXT NOT NULL,
label_custom_id TEXT NOT NULL,
account_id INTEGER NOT NULL,
FOREIGN KEY (message_custom_id) REFERENCES Messages (custom_id),
FOREIGN KEY (label_custom_id) REFERENCES Labels (custom_id),
FOREIGN KEY (account_id) REFERENCES Accounts (id)
);
-- !
UPDATE Information SET inf_value = '8' WHERE inf_key = 'schema_version';