fixed profile preferences

This commit is contained in:
masongga
2026-05-23 21:32:38 -06:00
parent 4b45ddd182
commit 82097f79ac
7 changed files with 385 additions and 67 deletions

View File

@@ -0,0 +1,21 @@
-- 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;