beteran-api-kgon-server-ser.../migrations/202208061300_api_kgon_game/up.sql
2022-08-29 04:01:16 +00:00

29 lines
1.0 KiB
SQL

CREATE TABLE IF NOT EXISTS api_kgon_games (
id BIGINT NOT NULL,
kgon_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_kgon_vendor_id
FOREIGN KEY(kgon_vendor_id)
REFERENCES api_kgon_vendors(id)
);
CREATE INDEX idx_api_kgon_games_kgon_vendor_id ON api_kgon_games (kgon_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);
-- 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();