35 lines
1.3 KiB
SQL
35 lines
1.3 KiB
SQL
-- SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
|
create table "proposals" (
|
|
"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,
|
|
"status" text not null,
|
|
"target_key" text not null,
|
|
"target_record_id" text,
|
|
"written_record_id" text,
|
|
"change" jsonb not null,
|
|
"evidence" jsonb not null,
|
|
"model" text not null,
|
|
"prompt_version" text not null,
|
|
"created_by" text not null,
|
|
"edited_by" text,
|
|
"edited_at" text,
|
|
"decided_by" text,
|
|
"decided_at" text,
|
|
"reason" text
|
|
);
|
|
|
|
create index "proposals_org_id_workspace_id_project_id_status_idx" on "proposals" ("org_id", "workspace_id", "project_id", "status");
|
|
|
|
create index "proposals_org_id_workspace_id_project_id_target_key_target_record_id_idx" on "proposals" ("org_id", "workspace_id", "project_id", "target_key", "target_record_id");
|
|
|
|
alter table "proposals" enable row level security;
|
|
|
|
alter table "proposals" force row level security;
|
|
|
|
create policy "proposals_tenant" on "proposals" using ("org_id" = nullif(current_setting('app.org_id', true), '')::uuid) with check ("org_id" = nullif(current_setting('app.org_id', true), '')::uuid);
|