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

21 lines
628 B
MySQL
Raw Normal View History

2022-08-11 16:16:56 +00:00
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();