Reapply "feat(loyalty): EnakPoint & EnakCoin" (#32)

This reverts commit 4e24f9bbb0.
This commit is contained in:
efrilm
2026-09-30 15:31:44 +07:00
parent 4e24f9bbb0
commit 582dc75543
195 changed files with 20058 additions and 2177 deletions
@@ -0,0 +1,17 @@
-- Devices of the customer app, so customers can get push notifications through FCM
-- (docs/prd-point-coin.md F5: the recipient of a transfer is notified). user_devices
-- only holds staff devices.
CREATE TABLE customer_devices (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
customer_id UUID NOT NULL REFERENCES customers(id) ON DELETE CASCADE,
device_id VARCHAR(255) NOT NULL,
platform VARCHAR(50) CHECK (platform IN ('android', 'ios', 'web')),
fcm_token VARCHAR(512) NOT NULL,
app_version VARCHAR(50),
last_active_at TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE UNIQUE INDEX idx_customer_devices_customer_device ON customer_devices(customer_id, device_id);
CREATE INDEX idx_customer_devices_fcm_token ON customer_devices(fcm_token);