99 lines
2.1 KiB
SQL
99 lines
2.1 KiB
SQL
-- Patched version of SQL/postgres.initial.sql for gecka/ident-switch.
|
|
-- Commit this into your Gitea fork at the same path, replacing the
|
|
-- upstream file. Only two changes from upstream:
|
|
-- 1. CREATE TABLE / CREATE INDEX -> IF NOT EXISTS
|
|
-- 2. INSERT INTO system -> upsert via ON CONFLICT
|
|
-- This makes the script safe to re-run against an already-migrated
|
|
-- database, which happens on every container restart unless
|
|
-- /var/www/html is persisted (composer re-installs "fresh" each time).
|
|
|
|
CREATE TABLE IF NOT EXISTS ident_switch
|
|
(
|
|
id
|
|
serial
|
|
PRIMARY KEY,
|
|
user_id
|
|
integer
|
|
NOT NULL
|
|
REFERENCES users(user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
iid
|
|
integer
|
|
NOT NULL
|
|
REFERENCES identities(identity_id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
UNIQUE,
|
|
parent_id
|
|
integer
|
|
DEFAULT NULL,
|
|
username
|
|
varchar(64),
|
|
password
|
|
varchar(255),
|
|
imap_host
|
|
varchar(64),
|
|
imap_port
|
|
integer
|
|
CHECK(imap_port > 0 AND imap_port <= 65535),
|
|
imap_delimiter
|
|
char(1),
|
|
label
|
|
varchar(32),
|
|
flags
|
|
integer
|
|
NOT NULL
|
|
DEFAULT(0),
|
|
smtp_host
|
|
varchar(64),
|
|
smtp_port
|
|
integer
|
|
CHECK(smtp_port > 0 AND smtp_port <= 65535),
|
|
smtp_auth
|
|
smallint
|
|
NOT NULL
|
|
DEFAULT(1),
|
|
smtp_username
|
|
varchar(64),
|
|
smtp_password
|
|
varchar(255),
|
|
sieve_host
|
|
varchar(64),
|
|
sieve_port
|
|
integer
|
|
CHECK(sieve_port > 0 AND sieve_port <= 65535),
|
|
sieve_auth
|
|
smallint
|
|
NOT NULL
|
|
DEFAULT(1),
|
|
sieve_username
|
|
varchar(64),
|
|
sieve_password
|
|
varchar(255),
|
|
notify_check
|
|
smallint
|
|
NOT NULL
|
|
DEFAULT(1),
|
|
notify_basic
|
|
smallint
|
|
DEFAULT NULL,
|
|
notify_sound
|
|
smallint
|
|
DEFAULT NULL,
|
|
notify_desktop
|
|
smallint
|
|
DEFAULT NULL,
|
|
drafts_mbox
|
|
varchar(64),
|
|
sent_mbox
|
|
varchar(64),
|
|
junk_mbox
|
|
varchar(64),
|
|
trash_mbox
|
|
varchar(64),
|
|
UNIQUE (user_id, label)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS IX_ident_switch_user_id ON ident_switch(user_id);
|
|
CREATE INDEX IF NOT EXISTS IX_ident_switch_iid ON ident_switch(iid);
|
|
CREATE INDEX IF NOT EXISTS IX_ident_switch_parent_id ON ident_switch(parent_id);
|
|
|
|
INSERT INTO system (name, value) VALUES ('ident_switch-version', '2026021000')
|
|
ON CONFLICT (name) DO UPDATE SET value = EXCLUDED.value; |