-- SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0 alter table "agent_step" add column "result" jsonb; create table "agent_thread" ( "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, "thread_id" text not null, "messages" jsonb not null ); alter table "agent_thread" add constraint "agent_thread_org_id_workspace_id_project_id_thread_id_key" unique nulls not distinct ("org_id", "workspace_id", "project_id", "thread_id"); alter table "agent_thread" enable row level security; alter table "agent_thread" force row level security; create policy "agent_thread_tenant" on "agent_thread" using ("org_id" = nullif(current_setting('app.org_id', true), '')::uuid) with check ("org_id" = nullif(current_setting('app.org_id', true), '')::uuid);