Files
apskel-pos-backend/migrations/000107_create_game_reward_counters.up.sql
T

17 lines
793 B
SQL
Raw Normal View History

-- EnakCoin given out as EnakGame rewards per scope per day, in Asia/Jakarta: the
-- Economy Guard's counters (docs/rfc-enakgame.md §5.8, §9). A reward over a limit is
-- cut to what is left of it.
CREATE TABLE game_reward_counters (
organization_id UUID NOT NULL,
scope_type VARCHAR(20) NOT NULL,
-- The customer, game, event or organization the scope_type names.
scope_id UUID NOT NULL,
-- 0001-01-01 for an event's limit over its whole run (PRD §35 Event Limit).
day DATE NOT NULL,
amount BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (organization_id, scope_type, scope_id, day),
CONSTRAINT chk_game_reward_counters_scope_type CHECK (scope_type IN ('USER', 'GAME', 'EVENT', 'GLOBAL')),
CONSTRAINT chk_game_reward_counters_amount CHECK (amount >= 0)
);