2022-08-11 16:16:56 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS banks (
|
|
|
|
id UUID DEFAULT uuid_generate_v4(),
|
2022-08-12 07:44:19 +00:00
|
|
|
name TEXT NOT NULL,
|
|
|
|
sort_order INTEGER NOT NULL,
|
2022-08-11 16:16:56 +00:00
|
|
|
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),
|
2022-08-12 07:44:19 +00:00
|
|
|
UNIQUE (name)
|
2022-08-11 16:16:56 +00:00
|
|
|
);
|
|
|
|
|
2022-08-12 07:44:19 +00:00
|
|
|
CREATE UNIQUE INDEX uidx_banks_name ON banks (name);
|
2022-08-11 16:16:56 +00:00
|
|
|
|
|
|
|
-- trigger (updated_at)
|
|
|
|
CREATE TRIGGER tg_banks_updated_at
|
|
|
|
BEFORE UPDATE
|
|
|
|
ON banks
|
|
|
|
FOR EACH ROW
|
|
|
|
EXECUTE PROCEDURE update_updated_at_column();
|