gitdataai/libs/migrate/sql/room_notifications/room_notifications_up_01.sql
ZhenYi b413edccaf refactor(migrate): replace hand-written migrations with SQL-file macro system
Replace individual Rust migration modules with a define_sql_migrations
macro that reads up/down SQL files via include_str!. Consolidate all
legacy single-file SQL into per-table directories and add full schema
migration coverage for 90+ tables.
2026-05-18 20:42:47 +08:00

30 lines
1.1 KiB
SQL

create table if not exists room_notifications
(
id uuid not null
primary key,
room uuid,
project uuid,
user_id uuid,
notification_type varchar(255) not null,
related_message_id uuid,
related_user_id uuid,
related_room_id uuid,
title varchar(255) not null,
content text,
metadata jsonb,
is_read boolean default false not null,
is_archived boolean default false not null,
created_at timestamp with time zone not null,
read_at timestamp with time zone,
expires_at timestamp with time zone
);
create index if not exists idx_room_notifications_user_id_is_read
on room_notifications (user_id, is_read);
create index if not exists idx_room_notifications_user_id_created_at
on room_notifications (user_id, created_at);
create index if not exists idx_room_notifications_expires_at
on room_notifications (expires_at);