beteran-api-kgon-server-ser.../migrations/202208061200_api_kgon_vendor/up.sql

28 lines
1.0 KiB
SQL

CREATE TABLE IF NOT EXISTS api_kgon_vendors (
id INTEGER NOT NULL,
company_id INTEGER NOT NULL,
vendor_id INTEGER NOT NULL,
max_bet_casino INTEGER NOT NULL,
max_bet_slot INTEGER NOT NULL,
is_enable CHAR(1) NOT NULL,
bet_count INTEGER NOT NULL,
key TEXT NOT NULL,
name TEXT NOT NULL,
category TEXT NOT NULL,
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)
);
CREATE INDEX idx_api_kgon_vendors_company_id ON api_kgon_vendors (company_id);
CREATE INDEX idx_api_kgon_vendors_vendor_id ON api_kgon_vendors (vendor_id);
CREATE INDEX idx_api_kgon_vendors_key ON api_kgon_vendors (key);
CREATE INDEX idx_api_kgon_vendors_category ON api_kgon_vendors (category);
-- trigger (updated_at)
CREATE TRIGGER tg_api_kgon_vendors_updated_at
BEFORE UPDATE
ON api_kgon_vendors
FOR EACH ROW
EXECUTE PROCEDURE update_updated_at_column();