fix migration number

This commit is contained in:
Efril
2026-05-10 13:30:40 +07:00
parent ddaf6df436
commit 9f653eef37
8 changed files with 0 additions and 0 deletions
@@ -0,0 +1,18 @@
-- Notification receivers table (links a notification to a specific user)
CREATE TABLE notification_receivers (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
notification_id UUID NOT NULL REFERENCES notifications(id) ON DELETE CASCADE,
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
is_read BOOLEAN NOT NULL DEFAULT FALSE,
read_at TIMESTAMP WITH TIME ZONE,
is_deleted BOOLEAN NOT NULL DEFAULT FALSE,
deleted_at TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Indexes
CREATE INDEX idx_notification_receivers_notification_id ON notification_receivers(notification_id);
CREATE INDEX idx_notification_receivers_user_id ON notification_receivers(user_id);
CREATE INDEX idx_notification_receivers_user_unread ON notification_receivers(user_id, is_read) WHERE is_deleted = FALSE;
CREATE UNIQUE INDEX idx_notification_receivers_unique ON notification_receivers(notification_id, user_id);