Spaces:
Sleeping
Sleeping
File size: 1,056 Bytes
3493993 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | begin;
-- Notification Preferences
create table if not exists notification_preferences (
id text primary key,
workspace_id text not null references workspaces(id) on delete cascade,
user_id text not null references users(id) on delete cascade,
event_type varchar(50) not null check (event_type in (
'collaboration_event', 'approval_request', 'publishing_failure', 'mention', 'project_activity'
)),
enabled boolean not null default true,
created_at timestamptz not null default now(),
unique(workspace_id, user_id, event_type)
);
create index ix_notification_preferences_workspace_user on notification_preferences(workspace_id, user_id);
-- RLS
alter table notification_preferences enable row level security;
alter table notification_preferences force row level security;
create policy notification_preferences_workspace_isolation on notification_preferences
using (workspace_id = current_setting('app.workspace_id', true))
with check (workspace_id = current_setting('app.workspace_id', true));
commit;
|