beteran-server-service/migrations/202207101000_member_settlement_setting/up.sql

43 lines
2.4 KiB
MySQL
Raw Permalink Normal View History

CREATE TYPE settlement_type AS ENUM ('rolling', 'loosing');
CREATE TYPE manual_payment_type AS ENUM ('all_child_partner', 'only_direct_partner', 'disable');
CREATE TABLE IF NOT EXISTS member_settlement_settings (
id UUID DEFAULT uuid_generate_v4(),
member_id UUID NOT NULL,
can_exchange BOOLEAN NOT NULL DEFAULT TRUE,
can_first_charge_comp BOOLEAN NOT NULL DEFAULT FALSE,
can_per_charge_comp BOOLEAN NOT NULL DEFAULT FALSE,
manual_payment_type_for_partner MANUAL_PAYMENT_TYPE DEFAULT 'all_child_partner',
settlement_type SETTLEMENT_TYPE DEFAULT 'rolling',
rate_casino DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_casino_loosing DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_casino_bacara DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_casino_roulette DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_casino_dragon_tiger DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_slot DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_slot_loosing DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_powerball_single DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_powerball_combo DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_powerladder_single DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_powerladder_combo DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_eos_single DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_eos_combo DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_bogglepowerball_single DOUBLE PRECISION NOT NULL DEFAULT 0.00,
rate_bogglepowerball_combo DOUBLE PRECISION NOT NULL DEFAULT 0.00,
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_settlement_settings_member_id
FOREIGN KEY(member_id)
REFERENCES members(id)
);
CREATE INDEX idx_member_settlement_settings_member_id ON member_settlement_settings (member_id);
-- trigger (updated_at)
CREATE TRIGGER tg_member_settlement_settings_updated_at
BEFORE UPDATE
ON member_settlement_settings
FOR EACH ROW
EXECUTE PROCEDURE update_updated_at_column();