panorama/daemon/migrations/20211013053733_initial.up.sql

33 lines
753 B
SQL

CREATE TABLE "accounts" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT
);
CREATE TABLE "mailboxes" (
"account" INTEGER NOT NULL,
"name" TEXT NOT NULL,
"uidvalidity" INTEGER NOT NULL,
PRIMARY KEY ("account", "name")
);
CREATE TABLE "messages" (
-- "id" TEXT PRIMARY KEY,
"id" INTEGER PRIMARY KEY,
"mailbox_acct" TEXT NOT NULL,
"mailbox" TEXT NOT NULL,
"uid" INTEGER NOT NULL,
"date" DATETIME,
"subject" TEXT,
"from" JSON,
"sender" JSON,
"reply_to" JSON,
"to" JSON,
"cc" JSON,
"bcc" JSON,
"in_reply_to" TEXT,
"message_id" TEXT,
"mbox" BLOB,
FOREIGN KEY ("mailbox_acct") REFERENCES "mailboxes" ("account"),
FOREIGN KEY ("mailbox") REFERENCES "mailboxes" ("name")
);