- scripts/prod: entrypoint, db-setup and schema.sql shipped in the image - scripts/dev: seed/clear db, psql and cleanup, run natively in the devcontainer instead of via docker-compose - move setup.cfg to the repo root so linters pick it up - Makefile targets run directly in the devcontainer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.1 KiB
SQL
32 lines
1.1 KiB
SQL
CREATE TABLE IF NOT EXISTS domains (
|
|
name varchar PRIMARY KEY
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS emails (
|
|
id serial PRIMARY KEY,
|
|
email varchar(255) NOT NULL UNIQUE
|
|
);
|
|
|
|
-- Make emails unique by lower-case comparison
|
|
CREATE UNIQUE INDEX IF NOT EXISTS email_unique_idx on emails (LOWER(email));
|
|
|
|
CREATE TABLE IF NOT EXISTS users (
|
|
id serial PRIMARY KEY,
|
|
email_id integer REFERENCES emails(id) ON DELETE RESTRICT NOT NULL UNIQUE,
|
|
passwordhash varchar(255) NOT NULL,
|
|
enabled boolean NOT NULL DEFAULT TRUE,
|
|
is_admin boolean NOT NULL DEFAULT FALSE,
|
|
can_use_different_alias_domain boolean NOT NULL DEFAULT FALSE,
|
|
note text NOT NULL DEFAULT ''
|
|
);
|
|
|
|
-- source=me2@finn.st destination=me@finn.st: me2 is an alias of me
|
|
CREATE TABLE IF NOT EXISTS aliases (
|
|
id serial PRIMARY KEY,
|
|
source_email_id integer REFERENCES emails(id) ON DELETE RESTRICT NOT NULL,
|
|
destination_user_id integer REFERENCES users(id) ON DELETE RESTRICT NOT NULL,
|
|
enabled boolean NOT NULL DEFAULT TRUE,
|
|
note text,
|
|
UNIQUE(source_email_id, destination_user_id)
|
|
);
|