29 lines
1.0 KiB
SQL
29 lines
1.0 KiB
SQL
CREATE TABLE IF NOT EXISTS api_kgon_games (
|
|
id INTEGER NOT NULL,
|
|
vendor_id INTEGER 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)
|
|
);
|
|
|
|
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);
|
|
|
|
-- 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();
|