create extension if not exists pgcrypto;

create table if not exists public.survey_responses (
  id uuid primary key default gen_random_uuid(),
  created_at timestamptz not null default now(),
  family_status text not null,
  child_ages text[] not null default '{}',
  situation text not null,
  biggest_challenges text,
  remember_plan text,
  time_energy text[] not null default '{}',
  remove_one text,
  depends text,
  stress text[] not null default '{}',
  tools text[] not null default '{}',
  frustration text,
  assistant_help text,
  desired_help text[] not null default '{}',
  one_problem text,
  adoption text,
  followup text,
  name text,
  contact text,
  metadata jsonb not null default '{}'::jsonb
);

alter table public.survey_responses enable row level security;

drop policy if exists "Allow anonymous survey inserts" on public.survey_responses;
create policy "Allow anonymous survey inserts"
on public.survey_responses
for insert
to anon
with check (true);
