Files
HaBit/supabase/migrations/20260524140000_profiles_focus_topics_text.sql
2026-05-23 21:32:38 -06:00

22 lines
633 B
SQL

-- Store profile preferences as JSON text instead of text[].
-- Safe when the column is already text (no-op cast).
alter table public.profiles
alter column focus_topics drop default;
alter table public.profiles
alter column focus_topics type text using (
case
when focus_topics is null then null
when pg_typeof(focus_topics)::text = 'text[]' then
case
when coalesce(array_length(focus_topics::text[], 1), 0) = 0 then null
else (focus_topics::text[])[1]
end
else focus_topics::text
end
);
alter table public.profiles
alter column focus_topics set default null;