23 lines
748 B
SQL
23 lines
748 B
SQL
CREATE TABLE IF NOT EXISTS sites (
|
|
id UUID DEFAULT uuid_generate_v4(),
|
|
url TEXT NOT NULL,
|
|
name TEXT NOT NULL,
|
|
path TEXT,
|
|
show BOOLEAN NOT NULL DEFAULT TRUE,
|
|
can_use BOOLEAN NOT NULL DEFAULT TRUE,
|
|
expires_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
|
|
created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
|
|
updated_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
|
|
PRIMARY KEY (id),
|
|
UNIQUE (url)
|
|
);
|
|
|
|
CREATE UNIQUE INDEX uidx_sites_url ON sites (url);
|
|
|
|
-- trigger (updated_at)
|
|
CREATE TRIGGER tg_sites_updated_at
|
|
BEFORE UPDATE
|
|
ON sites
|
|
FOR EACH ROW
|
|
EXECUTE PROCEDURE update_updated_at_column();
|