create table if not exists notification_messages ( id serial primary key, title varchar(200) not null, body text not null, category varchar(60) not null default 'general', source varchar(80) not null default 'system', priority varchar(20) not null default 'normal', is_read boolean not null default false, read_at timestamptz null, metadata_json jsonb not null default '{}'::jsonb, created_at timestamptz not null default now(), updated_at timestamptz not null default now() ); create index if not exists idx_notification_messages_unread_created_at on notification_messages (is_read, created_at desc, id desc);