diff options
author | Runxi Yu <me@runxiyu.org> | 2025-01-12 17:41:52 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-01-12 17:41:52 +0800 |
commit | 0715a254e8bc3a75607a173b0a3c8b5b67a5f4c9 (patch) | |
tree | 68d4774a88c5939c412d6f55b7184b76825e8037 /schema.sql | |
parent | Reformat code (diff) | |
download | maild-0715a254e8bc3a75607a173b0a3c8b5b67a5f4c9.tar.gz maild-0715a254e8bc3a75607a173b0a3c8b5b67a5f4c9.tar.zst maild-0715a254e8bc3a75607a173b0a3c8b5b67a5f4c9.zip |
Add PostgreSQL schema
Diffstat (limited to 'schema.sql')
-rw-r--r-- | schema.sql | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/schema.sql b/schema.sql new file mode 100644 index 0000000..5faeb74 --- /dev/null +++ b/schema.sql @@ -0,0 +1,20 @@ +CREATE TABLE accounts ( + id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + username TEXT, + password TEXT +); + +CREATE TABLE mailboxes ( + id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + account INTEGER NOT NULL, + FOREIGN KEY(account) REFERENCES accounts(id), + name TEXT, + UNIQUE(account, name) +); + +CREATE TABLE mail ( + id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + mailbox INTEGER NOT NULL, + FOREIGN KEY(mailbox) REFERENCES mailboxes(id), + data bytea +); |