This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
create table "documents_document" (
|
||||
"id" uuid primary key,
|
||||
"version" integer not null,
|
||||
"created_at" timestamptz not null,
|
||||
"updated_at" timestamptz not null,
|
||||
"org_id" uuid not null,
|
||||
"workspace_id" uuid not null,
|
||||
"project_id" uuid not null,
|
||||
"file_id" uuid not null,
|
||||
"filename" text not null,
|
||||
"status" text not null,
|
||||
"ocr_job_id" integer,
|
||||
"page_count" integer,
|
||||
"proposed_count" integer,
|
||||
"failure_code" text,
|
||||
"finished_at" text
|
||||
);
|
||||
|
||||
alter table "documents_document" add constraint "documents_document_org_id_workspace_id_project_id_file_id_key" unique nulls not distinct ("org_id", "workspace_id", "project_id", "file_id");
|
||||
|
||||
create index "documents_document_org_id_workspace_id_project_id_status_idx" on "documents_document" ("org_id", "workspace_id", "project_id", "status");
|
||||
|
||||
create table "documents_line" (
|
||||
"id" uuid primary key,
|
||||
"version" integer not null,
|
||||
"created_at" timestamptz not null,
|
||||
"updated_at" timestamptz not null,
|
||||
"org_id" uuid not null,
|
||||
"workspace_id" uuid not null,
|
||||
"project_id" uuid not null,
|
||||
"document_id" uuid not null,
|
||||
"proposal_id" uuid not null,
|
||||
"label" text not null,
|
||||
"value" text not null,
|
||||
"page" integer not null,
|
||||
"position" integer not null,
|
||||
"quote" text not null,
|
||||
"edited" boolean not null,
|
||||
"approved_by" text not null
|
||||
);
|
||||
|
||||
alter table "documents_line" add constraint "documents_line_org_id_workspace_id_project_id_proposal_id_key" unique nulls not distinct ("org_id", "workspace_id", "project_id", "proposal_id");
|
||||
|
||||
create index "documents_line_org_id_workspace_id_project_id_document_id_idx" on "documents_line" ("org_id", "workspace_id", "project_id", "document_id");
|
||||
|
||||
alter table "documents_document" enable row level security;
|
||||
|
||||
alter table "documents_document" force row level security;
|
||||
|
||||
create policy "documents_document_tenant" on "documents_document" using ("org_id" = nullif(current_setting('app.org_id', true), '')::uuid) with check ("org_id" = nullif(current_setting('app.org_id', true), '')::uuid);
|
||||
|
||||
alter table "documents_line" enable row level security;
|
||||
|
||||
alter table "documents_line" force row level security;
|
||||
|
||||
create policy "documents_line_tenant" on "documents_line" using ("org_id" = nullif(current_setting('app.org_id', true), '')::uuid) with check ("org_id" = nullif(current_setting('app.org_id', true), '')::uuid);
|
||||
Reference in New Issue
Block a user