chore: establish local platform baseline
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE integration_issue (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
public_id uuid NOT NULL UNIQUE DEFAULT gen_random_uuid(),
|
||||
tenant_id uuid NOT NULL REFERENCES tenant(id),
|
||||
phenomenon varchar(2000) NOT NULL,
|
||||
device_id uuid,
|
||||
conversation_id uuid,
|
||||
occurred_at timestamptz NOT NULL,
|
||||
request_id varchar(128),
|
||||
responsible_party varchar(120) NOT NULL,
|
||||
status varchar(24) NOT NULL DEFAULT 'OPEN'
|
||||
CHECK (status IN ('OPEN','IN_PROGRESS','RESOLVED','VERIFIED','CLOSED')),
|
||||
resolution_result varchar(4000),
|
||||
regression_conclusion varchar(4000),
|
||||
created_by uuid NOT NULL,
|
||||
updated_by uuid NOT NULL,
|
||||
version bigint NOT NULL DEFAULT 1 CHECK (version > 0),
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
CONSTRAINT integration_issue_device_tenant_fk
|
||||
FOREIGN KEY (device_id, tenant_id) REFERENCES device(id, tenant_id),
|
||||
CONSTRAINT integration_issue_conversation_tenant_fk
|
||||
FOREIGN KEY (conversation_id, tenant_id) REFERENCES conversation(id, tenant_id),
|
||||
CONSTRAINT integration_issue_creator_tenant_fk
|
||||
FOREIGN KEY (created_by, tenant_id) REFERENCES user_account(id, tenant_id),
|
||||
CONSTRAINT integration_issue_updater_tenant_fk
|
||||
FOREIGN KEY (updated_by, tenant_id) REFERENCES user_account(id, tenant_id),
|
||||
CONSTRAINT integration_issue_resolution_check CHECK (
|
||||
status NOT IN ('RESOLVED','VERIFIED','CLOSED') OR NULLIF(btrim(resolution_result),'') IS NOT NULL
|
||||
),
|
||||
CONSTRAINT integration_issue_regression_check CHECK (
|
||||
status NOT IN ('VERIFIED','CLOSED') OR NULLIF(btrim(regression_conclusion),'') IS NOT NULL
|
||||
)
|
||||
);
|
||||
|
||||
CREATE INDEX integration_issue_tenant_status_updated_idx
|
||||
ON integration_issue (tenant_id, status, updated_at DESC, id DESC);
|
||||
CREATE INDEX integration_issue_device_idx
|
||||
ON integration_issue (tenant_id, device_id, occurred_at DESC)
|
||||
WHERE device_id IS NOT NULL;
|
||||
CREATE INDEX integration_issue_conversation_idx
|
||||
ON integration_issue (tenant_id, conversation_id, occurred_at DESC)
|
||||
WHERE conversation_id IS NOT NULL;
|
||||
|
||||
COMMENT ON TABLE integration_issue IS 'Tenant-scoped integration issue ledger required by P0282; stores only diagnostic references and resolution workflow, never transcript or recording content.';
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user