ALTER TABLE medreport.account_params
ADD is_smoker boolean;


CREATE UNIQUE INDEX params_account_id_pkey ON medreport.account_params USING btree (account_id);
alter table medreport.account_params add constraint "params_account_id_pkey" UNIQUE using index "params_account_id_pkey";

alter policy "users can insert their params"
on "medreport"."account_params"
to authenticated
with check (
  account_id in (
    select id 
    from medreport.accounts 
    where primary_owner_user_id = auth.uid()
  )
);

alter policy "users can read their params"
on "medreport"."account_params"
to authenticated
using (
  account_id in (
    select id 
    from medreport.accounts 
    where primary_owner_user_id = auth.uid()
  )
);

create policy "users can update their params"
on "medreport"."account_params"
as PERMISSIVE
for UPDATE
to authenticated
using (
  account_id in (
    select id 
    from medreport.accounts 
    where primary_owner_user_id = auth.uid()
  )
);


