-- SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0 create table "files_file" ( "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, "storage_key" text not null, "filename" text not null, "content_type" text not null, "size" integer, "sha256" text, "uploaded_by" uuid not null, "stored_at" text, "upload_id" text, "declared_size" integer, "part_size" integer, "deleting_at" text ); alter table "files_file" add constraint "files_file_org_id_workspace_id_project_id_storage_key_key" unique nulls not distinct ("org_id", "workspace_id", "project_id", "storage_key"); create index "files_file_org_id_workspace_id_project_id_status_idx" on "files_file" ("org_id", "workspace_id", "project_id", "status"); create index "files_file_org_id_workspace_id_project_id_sha256_idx" on "files_file" ("org_id", "workspace_id", "project_id", "sha256"); alter table "files_file" enable row level security; alter table "files_file" force row level security; create policy "files_file_tenant" on "files_file" using ("org_id" = nullif(current_setting('app.org_id', true), '')::uuid) with check ("org_id" = nullif(current_setting('app.org_id', true), '')::uuid);