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

22 lines
676 B
SQL

CREATE TABLE IF NOT EXISTS banks (
id UUID DEFAULT uuid_generate_v4(),
name TEXT NOT NULL,
sort_order INTEGER NOT NULL,
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 (name)
);
CREATE UNIQUE INDEX uidx_banks_name ON banks (name);
-- trigger (updated_at)
CREATE TRIGGER tg_banks_updated_at
BEFORE UPDATE
ON banks
FOR EACH ROW
EXECUTE PROCEDURE update_updated_at_column();