-- Migration to add dedicated privacy_settings table
-- execute this in your Supabase SQL editor or as part of a migration script.

create table if not exists public.privacy_settings (
  user_id integer not null,
  profile_public boolean not null default true,
  show_builds boolean not null default true,
  constraint privacy_settings_pkey primary key (user_id),
  constraint fk_privacy_user foreign key (user_id) references users (user_id)
) tablespace pg_default;

-- Optional: copy existing data from users.privacy_settings
-- insert into public.privacy_settings (user_id, profile_public, show_builds)
-- select
--   user_id,
--   (privacy_settings->>'profilePublic')::boolean,
--   (privacy_settings->>'showBuilds')::boolean
-- from public.users
-- where privacy_settings is not null;
