-- Mirror of the production Supabase migration for operators who apply backend
-- SQL bundles directly.
alter table chat_sessions
  add column if not exists context_data jsonb;

update chat_sessions
set context_data = '{}'::jsonb
where context_data is null;

alter table chat_sessions
  alter column context_data set default '{}'::jsonb,
  alter column context_data set not null;
