mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-02 08:40:53 +03:00
7e1c02db95
This pull request removes constraints and adds foreign key references to the brain tables in order to improve data integrity and enforce referential integrity.
46 lines
2.2 KiB
SQL
46 lines
2.2 KiB
SQL
alter table "public"."brain_subscription_invitations" drop constraint "brain_subscription_invitations_brain_id_fkey";
|
|
|
|
alter table "public"."brains_users" drop constraint "brains_users_brain_id_fkey";
|
|
|
|
alter table "public"."brains_vectors" drop constraint "brains_vectors_brain_id_fkey";
|
|
|
|
alter table "public"."chat_history" drop constraint "chat_history_brain_id_fkey";
|
|
|
|
alter table "public"."knowledge" drop constraint "knowledge_brain_id_fkey";
|
|
|
|
alter table "public"."knowledge" drop constraint "knowledge_pkey";
|
|
|
|
drop index if exists "public"."knowledge_pkey";
|
|
|
|
alter table "public"."integrations_user" add column "last_synced" timestamp with time zone default now();
|
|
|
|
alter table "public"."brain_subscription_invitations" add constraint "brain_subscription_invitations_brain_id_fkey" FOREIGN KEY (brain_id) REFERENCES brains(brain_id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
|
|
|
|
alter table "public"."brain_subscription_invitations" validate constraint "brain_subscription_invitations_brain_id_fkey";
|
|
|
|
alter table "public"."brains_users" add constraint "brains_users_brain_id_fkey" FOREIGN KEY (brain_id) REFERENCES brains(brain_id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
|
|
|
|
alter table "public"."brains_users" validate constraint "brains_users_brain_id_fkey";
|
|
|
|
alter table "public"."brains_vectors" add constraint "brains_vectors_brain_id_fkey" FOREIGN KEY (brain_id) REFERENCES brains(brain_id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
|
|
|
|
alter table "public"."brains_vectors" validate constraint "brains_vectors_brain_id_fkey";
|
|
|
|
alter table "public"."chat_history" add constraint "chat_history_brain_id_fkey" FOREIGN KEY (brain_id) REFERENCES brains(brain_id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
|
|
|
|
alter table "public"."chat_history" validate constraint "chat_history_brain_id_fkey";
|
|
|
|
alter table "public"."knowledge" add constraint "knowledge_brain_id_fkey" FOREIGN KEY (brain_id) REFERENCES brains(brain_id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
|
|
|
|
alter table "public"."knowledge" validate constraint "knowledge_brain_id_fkey";
|
|
|
|
create policy "Enable all for service role"
|
|
on "public"."integrations_user"
|
|
as permissive
|
|
for all
|
|
to service_role
|
|
with check (true);
|
|
|
|
|
|
|