beteran-api-kgon-server-ser.../migrations/202208061300_api_kgon_game/up.sql

29 lines
1.0 KiB
MySQL
Raw Normal View History

2022-08-16 17:00:26 +00:00
CREATE TABLE IF NOT EXISTS api_kgon_games (
id BIGINT NOT NULL,
vendor_id BIGINT NOT NULL,
key TEXT NOT NULL,
names TEXT NOT NULL,
platform TEXT NOT NULL,
category TEXT NOT NULL,
game_type TEXT NOT NULL,
image 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_api_kgon_games_vendor_id
FOREIGN KEY(vendor_id)
REFERENCES api_kgon_vendors(id)
);
2022-08-17 17:45:00 +00:00
CREATE INDEX idx_api_kgon_games_vendor_id ON api_kgon_games (vendor_id);
CREATE INDEX idx_api_kgon_games_key ON api_kgon_games (key);
CREATE INDEX idx_api_kgon_games_category ON api_kgon_games (category);
CREATE INDEX idx_api_kgon_games_game_type ON api_kgon_games (game_type);
2022-08-16 17:00:26 +00:00
-- trigger (updated_at)
CREATE TRIGGER tg_api_kgon_games_updated_at
BEFORE UPDATE
ON api_kgon_games
FOR EACH ROW
EXECUTE PROCEDURE update_updated_at_column();