beteran-server-service/migrations/202206201420_member_referrer/up.sql

23 lines
744 B
MySQL
Raw Permalink Normal View History

2022-08-19 07:06:00 +00:00
CREATE TABLE IF NOT EXISTS member_referrers (
id UUID DEFAULT uuid_generate_v4(),
member_id UUID NOT NULL,
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),
CONSTRAINT fk_member_referrers_member_id
FOREIGN KEY(member_id)
REFERENCES members(id)
);
CREATE INDEX idx_member_referrers_member_id ON member_referrers (member_id);
-- trigger (updated_at)
CREATE TRIGGER tg_member_referrers_updated_at
BEFORE UPDATE
ON member_referrers
FOR EACH ROW
EXECUTE PROCEDURE update_updated_at_column();