quivr/backend/supabase/migrations/20240820091834_notion-sync.sql
Chloé Daems 42f4bb724e
feat(integration): Notion (#3173)
# Description

Fix multiple notion bugs 👍 

-> Delete your notion sync and all the notion files from the db
-> Ensure a sync is not already running before launching a sync.
-> Add a status to subscribe to for user_sync

---------

Co-authored-by: Antoine Dewez <44063631+Zewed@users.noreply.github.com>
Co-authored-by: Stan Girard <stan@quivr.app>
Co-authored-by: aminediro <aminedirhoussi1@gmail.com>
Co-authored-by: Stan Girard <girard.stanislas@gmail.com>
2024-09-19 05:37:04 -07:00

50 lines
2.2 KiB
SQL

create table "public"."notion_sync" (
"id" UUID DEFAULT uuid_generate_v4() not null,
"notion_id" uuid not null,
"parent_id" uuid,
"is_folder" boolean,
"icon" text,
"last_modified" timestamp with time zone,
"web_view_link" text,
"type" text,
"name" text,
"mime_type" text,
"user_id" text
);
alter table "public"."notion_sync" enable row level security;
alter table "public"."syncs_active"
add column if not exists "notification_id" uuid;
CREATE UNIQUE INDEX notion_sync_pkey ON public.notion_sync USING btree (id, notion_id);
alter table "public"."notion_sync"
add constraint "notion_sync_pkey" PRIMARY KEY using index "notion_sync_pkey";
grant delete on table "public"."notion_sync" to "anon";
grant insert on table "public"."notion_sync" to "anon";
grant references on table "public"."notion_sync" to "anon";
grant select on table "public"."notion_sync" to "anon";
grant trigger on table "public"."notion_sync" to "anon";
grant truncate on table "public"."notion_sync" to "anon";
grant update on table "public"."notion_sync" to "anon";
grant delete on table "public"."notion_sync" to "authenticated";
grant insert on table "public"."notion_sync" to "authenticated";
grant references on table "public"."notion_sync" to "authenticated";
grant select on table "public"."notion_sync" to "authenticated";
grant trigger on table "public"."notion_sync" to "authenticated";
grant truncate on table "public"."notion_sync" to "authenticated";
grant update on table "public"."notion_sync" to "authenticated";
grant delete on table "public"."notion_sync" to "service_role";
grant insert on table "public"."notion_sync" to "service_role";
grant references on table "public"."notion_sync" to "service_role";
grant select on table "public"."notion_sync" to "service_role";
grant trigger on table "public"."notion_sync" to "service_role";
grant truncate on table "public"."notion_sync" to "service_role";
grant update on table "public"."notion_sync" to "service_role";
CREATE UNIQUE INDEX notion_sync_notion_id_key ON public.notion_sync USING btree (notion_id);
alter table "public"."notion_sync" add constraint "notion_sync_notion_id_key" UNIQUE using index "notion_sync_notion_id_key";