Skip to main content

infra/sql/0002_psa_resources.sql

Metadata

Indexed Symbols

No indexed functions/methods detected in this file.

Markdown Headings (if applicable)

No markdown headings detected.

Source Preview

-- Generic resource storage for API-backed PSA entities.
-- This allows rapid iteration over the full ITFlow-equivalent resource surface
-- while preserving strict workspace-level isolation in Postgres.

create table if not exists psa_resources (
resource_type text not null,
workspace_id uuid not null,
record_id uuid not null,
payload jsonb not null,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now(),
primary key (resource_type, workspace_id, record_id)
);

create index if not exists idx_psa_resources_workspace_type
on psa_resources(workspace_id, resource_type, created_at desc);

create index if not exists idx_psa_resources_payload_gin
on psa_resources using gin(payload);