Merge origin/main into agent-guided birth time rectification
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
begin;
|
||||
|
||||
create table if not exists public.chart_profiles (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
user_id uuid not null references auth.users(id) on delete cascade,
|
||||
role text not null default 'other' check (role in ('self', 'other')),
|
||||
profile jsonb not null check (jsonb_typeof(profile) = 'object'),
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
create index if not exists chart_profiles_user_updated_at_idx
|
||||
on public.chart_profiles (user_id, updated_at desc);
|
||||
|
||||
create unique index if not exists chart_profiles_one_self_per_user_idx
|
||||
on public.chart_profiles (user_id)
|
||||
where role = 'self';
|
||||
|
||||
alter table public.chart_profiles enable row level security;
|
||||
|
||||
drop policy if exists chart_profiles_select_own on public.chart_profiles;
|
||||
create policy chart_profiles_select_own
|
||||
on public.chart_profiles
|
||||
for select
|
||||
to authenticated
|
||||
using ((select auth.uid()) = user_id);
|
||||
|
||||
drop policy if exists chart_profiles_insert_own on public.chart_profiles;
|
||||
create policy chart_profiles_insert_own
|
||||
on public.chart_profiles
|
||||
for insert
|
||||
to authenticated
|
||||
with check ((select auth.uid()) = user_id);
|
||||
|
||||
drop policy if exists chart_profiles_update_own on public.chart_profiles;
|
||||
create policy chart_profiles_update_own
|
||||
on public.chart_profiles
|
||||
for update
|
||||
to authenticated
|
||||
using ((select auth.uid()) = user_id)
|
||||
with check ((select auth.uid()) = user_id);
|
||||
|
||||
drop policy if exists chart_profiles_delete_own on public.chart_profiles;
|
||||
create policy chart_profiles_delete_own
|
||||
on public.chart_profiles
|
||||
for delete
|
||||
to authenticated
|
||||
using ((select auth.uid()) = user_id);
|
||||
|
||||
revoke all on table public.chart_profiles from anon, authenticated, service_role;
|
||||
grant select on table public.chart_profiles to authenticated;
|
||||
grant insert (id, user_id, role, profile, updated_at) on table public.chart_profiles to authenticated;
|
||||
grant update (role, profile, updated_at) on table public.chart_profiles to authenticated;
|
||||
grant delete on table public.chart_profiles to authenticated;
|
||||
|
||||
commit;
|
||||
@@ -0,0 +1,36 @@
|
||||
begin;
|
||||
|
||||
create table if not exists public.synastry_reports (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
user_id uuid not null references auth.users(id) on delete cascade,
|
||||
partner_name text not null default '对方',
|
||||
report jsonb not null check (jsonb_typeof(report) = 'object'),
|
||||
created_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
create index if not exists synastry_reports_user_created_at_idx
|
||||
on public.synastry_reports (user_id, created_at desc);
|
||||
|
||||
alter table public.synastry_reports enable row level security;
|
||||
|
||||
drop policy if exists synastry_reports_select_own on public.synastry_reports;
|
||||
create policy synastry_reports_select_own
|
||||
on public.synastry_reports for select to authenticated
|
||||
using ((select auth.uid()) = user_id);
|
||||
|
||||
drop policy if exists synastry_reports_insert_own on public.synastry_reports;
|
||||
create policy synastry_reports_insert_own
|
||||
on public.synastry_reports for insert to authenticated
|
||||
with check ((select auth.uid()) = user_id);
|
||||
|
||||
drop policy if exists synastry_reports_delete_own on public.synastry_reports;
|
||||
create policy synastry_reports_delete_own
|
||||
on public.synastry_reports for delete to authenticated
|
||||
using ((select auth.uid()) = user_id);
|
||||
|
||||
revoke all on table public.synastry_reports from anon, authenticated, service_role;
|
||||
grant select on table public.synastry_reports to authenticated;
|
||||
grant insert (id, user_id, partner_name, report, created_at) on table public.synastry_reports to authenticated;
|
||||
grant delete on table public.synastry_reports to authenticated;
|
||||
|
||||
commit;
|
||||
@@ -0,0 +1,25 @@
|
||||
begin;
|
||||
|
||||
drop policy if exists profiles_insert_own on public.profiles;
|
||||
create policy profiles_insert_own
|
||||
on public.profiles
|
||||
for insert
|
||||
to authenticated
|
||||
with check ((select auth.uid()) = id);
|
||||
|
||||
grant insert (
|
||||
id,
|
||||
name,
|
||||
birth_date,
|
||||
birth_time,
|
||||
country_code,
|
||||
province_code,
|
||||
city_code,
|
||||
district_code,
|
||||
latitude,
|
||||
longitude,
|
||||
timezone_offset,
|
||||
updated_at
|
||||
) on public.profiles to authenticated;
|
||||
|
||||
commit;
|
||||
@@ -0,0 +1,53 @@
|
||||
begin;
|
||||
|
||||
grant select, insert, update on table public.profiles to service_role;
|
||||
|
||||
grant select (
|
||||
id,
|
||||
email,
|
||||
credits,
|
||||
created_at,
|
||||
updated_at,
|
||||
name,
|
||||
birth_date,
|
||||
birth_time,
|
||||
country_code,
|
||||
province_code,
|
||||
city_code,
|
||||
district_code,
|
||||
latitude,
|
||||
longitude,
|
||||
timezone_offset
|
||||
) on public.profiles to service_role;
|
||||
|
||||
grant insert (
|
||||
id,
|
||||
email,
|
||||
name,
|
||||
birth_date,
|
||||
birth_time,
|
||||
country_code,
|
||||
province_code,
|
||||
city_code,
|
||||
district_code,
|
||||
latitude,
|
||||
longitude,
|
||||
timezone_offset,
|
||||
updated_at
|
||||
) on public.profiles to service_role;
|
||||
|
||||
grant update (
|
||||
name,
|
||||
birth_date,
|
||||
birth_time,
|
||||
country_code,
|
||||
province_code,
|
||||
city_code,
|
||||
district_code,
|
||||
latitude,
|
||||
longitude,
|
||||
timezone_offset,
|
||||
updated_at
|
||||
) on public.profiles to service_role;
|
||||
|
||||
commit;
|
||||
Reference in New Issue
Block a user