beteran-server-service/migrations/202206201230_member_class/up.sql

19 lines
590 B
SQL

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