beteran-server-service/migrations/202206181000_site/up.sql

24 lines
711 B
MySQL
Raw Permalink Normal View History

2022-08-08 00:59:34 +00:00
CREATE TABLE IF NOT EXISTS sites (
2022-08-05 04:10:34 +00:00
id UUID DEFAULT uuid_generate_v4(),
url TEXT NOT NULL,
2022-08-10 02:43:22 +00:00
name TEXT,
2022-08-10 01:59:01 +00:00
path TEXT,
2022-08-07 10:43:16 +00:00
show BOOLEAN NOT NULL DEFAULT TRUE,
2022-08-08 01:51:31 +00:00
can_use BOOLEAN NOT NULL DEFAULT TRUE,
2022-08-10 02:43:22 +00:00
memo TEXT,
expires_at BIGINT,
2022-08-05 04:10:34 +00:00
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)
);
2022-08-08 00:59:34 +00:00
CREATE UNIQUE INDEX uidx_sites_url ON sites (url);
2022-08-05 04:10:34 +00:00
-- trigger (updated_at)
2022-08-08 00:59:34 +00:00
CREATE TRIGGER tg_sites_updated_at
2022-08-05 04:10:34 +00:00
BEFORE UPDATE
2022-08-08 00:59:34 +00:00
ON sites
2022-08-05 04:10:34 +00:00
FOR EACH ROW
EXECUTE PROCEDURE update_updated_at_column();