Add Tiers and Game Prize

This commit is contained in:
Aditya Siregar
2025-09-17 19:30:17 +07:00
parent 12ee54390f
commit 201e24041b
66 changed files with 6365 additions and 2 deletions
@@ -0,0 +1,22 @@
CREATE TABLE customer_points (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
customer_id UUID NOT NULL,
balance BIGINT DEFAULT 0 NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
CONSTRAINT fk_customer_points_customer
FOREIGN KEY (customer_id)
REFERENCES customers(id)
ON DELETE CASCADE,
CONSTRAINT chk_customer_points_balance_non_negative
CHECK (balance >= 0)
);
-- Create indexes
CREATE INDEX idx_customer_points_customer_id ON customer_points(customer_id);
CREATE INDEX idx_customer_points_updated_at ON customer_points(updated_at);
-- Create unique constraint to ensure one point record per customer
CREATE UNIQUE INDEX idx_customer_points_unique_customer ON customer_points(customer_id);