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);
