beteran-server-service/migrations/202207011000_bank/up.sql

21 lines
628 B
SQL

CREATE TABLE IF NOT EXISTS banks (
id UUID DEFAULT uuid_generate_v4(),
name TEXT,
show BOOLEAN NOT NULL DEFAULT TRUE,
can_use BOOLEAN NOT NULL DEFAULT TRUE,
memo TEXT,
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_banks_url ON banks (url);
-- trigger (updated_at)
CREATE TRIGGER tg_banks_updated_at
BEFORE UPDATE
ON banks
FOR EACH ROW
EXECUTE PROCEDURE update_updated_at_column();