Files
ok_r/supabase/migrations/20260128000002_add_help_request_fields.sql
karlcarlo 095f02700f feat: 添加数据库迁移脚本和 Supabase 工具配置
添加迁移脚本以支持数据库版本管理,配置 pnpm workspace 仅构建 supabase 依赖
新增用户登录字段和任务帮助请求功能,禁用 tasks 和 task_steps 表的 RLS
更新环境变量示例以支持自托管 Supabase 实例
2026-01-29 02:41:10 +08:00

57 lines
2.0 KiB
SQL

alter table public.tasks
add column if not exists help_requested_to_user_id uuid null,
add column if not exists help_requested_by_user_id uuid null,
add column if not exists help_requested_at timestamptz null;
alter table public.task_steps
add column if not exists help_requested_to_user_id uuid null,
add column if not exists help_requested_by_user_id uuid null,
add column if not exists help_requested_at timestamptz null;
do $$
begin
if not exists (
select 1 from pg_constraint where conname = 'tasks_help_requested_to_user_id_fkey'
) then
alter table public.tasks
add constraint tasks_help_requested_to_user_id_fkey
foreign key (help_requested_to_user_id) references public.users(id);
end if;
if not exists (
select 1 from pg_constraint where conname = 'tasks_help_requested_by_user_id_fkey'
) then
alter table public.tasks
add constraint tasks_help_requested_by_user_id_fkey
foreign key (help_requested_by_user_id) references public.users(id);
end if;
if not exists (
select 1 from pg_constraint where conname = 'task_steps_help_requested_to_user_id_fkey'
) then
alter table public.task_steps
add constraint task_steps_help_requested_to_user_id_fkey
foreign key (help_requested_to_user_id) references public.users(id);
end if;
if not exists (
select 1 from pg_constraint where conname = 'task_steps_help_requested_by_user_id_fkey'
) then
alter table public.task_steps
add constraint task_steps_help_requested_by_user_id_fkey
foreign key (help_requested_by_user_id) references public.users(id);
end if;
end $$;
create index if not exists tasks_help_requested_to_user_id_idx
on public.tasks(help_requested_to_user_id);
create index if not exists tasks_help_requested_by_user_id_idx
on public.tasks(help_requested_by_user_id);
create index if not exists task_steps_help_requested_to_user_id_idx
on public.task_steps(help_requested_to_user_id);
create index if not exists task_steps_help_requested_by_user_id_idx
on public.task_steps(help_requested_by_user_id);