beteran-server-service/migrations/202206201210_member_site/up.sql
2022-08-06 11:37:51 +00:00

20 lines
625 B
SQL

CREATE TABLE IF NOT EXISTS member_sites (
id UUID DEFAULT uuid_generate_v4(),
url TEXT NOT NULL,
use BOOLEAN NOT NULL DEFAULT TRUE,
created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
updated_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
deleted_at BIGINT,
PRIMARY KEY (id),
UNIQUE (url)
);
CREATE UNIQUE INDEX uidx_member_sites_url ON member_sites (url);
-- trigger (updated_at)
CREATE TRIGGER tg_member_sites_updated_at
BEFORE UPDATE
ON member_sites
FOR EACH ROW
EXECUTE PROCEDURE update_updated_at_column();