Skip to content

The open-source app everyone uses to manage agents at work

1.7 MB
Raw Blame
{
  "id": "7832df38-fa1b-4687-bd06-eccbc29bd28c",
  "prevId": "3e17203b-ec95-41e9-8363-685982450199",
  "version": "7",
  "dialect": "postgresql",
  "tables": {
    "public.accounting_runtime_baselines": {
      "name": "accounting_runtime_baselines",
      "schema": "",
      "columns": {
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "cost_cents": {
          "name": "cost_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true
        },
        "input_tokens": {
          "name": "input_tokens",
          "type": "numeric(30, 0)",
          "primaryKey": false,
          "notNull": true
        },
        "cached_input_tokens": {
          "name": "cached_input_tokens",
          "type": "numeric(30, 0)",
          "primaryKey": false,
          "notNull": true
        },
        "output_tokens": {
          "name": "output_tokens",
          "type": "numeric(30, 0)",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "accounting_runtime_baselines_company_idx": {
          "name": "accounting_runtime_baselines_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "accounting_runtime_baselines_agent_id_agents_id_fk": {
          "name": "accounting_runtime_baselines_agent_id_agents_id_fk",
          "tableFrom": "accounting_runtime_baselines",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "accounting_runtime_baselines_company_id_companies_id_fk": {
          "name": "accounting_runtime_baselines_company_id_companies_id_fk",
          "tableFrom": "accounting_runtime_baselines",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.billing_invoice_lines": {
      "name": "billing_invoice_lines",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "invoice_id": {
          "name": "invoice_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "external_id": {
          "name": "external_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "amount_cents": {
          "name": "amount_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true
        },
        "occurred_at": {
          "name": "occurred_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "cost_event_id": {
          "name": "cost_event_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "provider_request_id": {
          "name": "provider_request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "model": {
          "name": "model",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "pricing": {
          "name": "pricing",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        }
      },
      "indexes": {
        "billing_invoice_lines_identity_idx": {
          "name": "billing_invoice_lines_identity_idx",
          "columns": [
            {
              "expression": "invoice_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "external_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "billing_invoice_lines_company_idx": {
          "name": "billing_invoice_lines_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "invoice_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "billing_invoice_lines_company_id_companies_id_fk": {
          "name": "billing_invoice_lines_company_id_companies_id_fk",
          "tableFrom": "billing_invoice_lines",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "billing_invoice_lines_invoice_id_billing_invoices_id_fk": {
          "name": "billing_invoice_lines_invoice_id_billing_invoices_id_fk",
          "tableFrom": "billing_invoice_lines",
          "tableTo": "billing_invoices",
          "columnsFrom": [
            "invoice_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "billing_invoice_lines_cost_event_id_cost_events_id_fk": {
          "name": "billing_invoice_lines_cost_event_id_cost_events_id_fk",
          "tableFrom": "billing_invoice_lines",
          "tableTo": "cost_events",
          "columnsFrom": [
            "cost_event_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "billing_invoice_lines_amount_check": {
          "name": "billing_invoice_lines_amount_check",
          "value": "\"billing_invoice_lines\".\"amount_cents\" >= 0"
        },
        "billing_invoice_lines_kind_check": {
          "name": "billing_invoice_lines_kind_check",
          "value": "\"billing_invoice_lines\".\"kind\" in ('inference', 'fee', 'credit')"
        }
      },
      "isRLSEnabled": false
    },
    "public.billing_invoices": {
      "name": "billing_invoices",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "biller": {
          "name": "biller",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "external_id": {
          "name": "external_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "currency": {
          "name": "currency",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "receipt_hash": {
          "name": "receipt_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "imported_by": {
          "name": "imported_by",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "billing_invoices_identity_idx": {
          "name": "billing_invoices_identity_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "biller",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "external_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "billing_invoices_company_id_companies_id_fk": {
          "name": "billing_invoices_company_id_companies_id_fk",
          "tableFrom": "billing_invoices",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.budget_reservations": {
      "name": "budget_reservations",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "prompt_injection_invocation_id": {
          "name": "prompt_injection_invocation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "decision_invocation_id": {
          "name": "decision_invocation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "fast_response_request_id": {
          "name": "fast_response_request_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "project_id": {
          "name": "project_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "amount_cents": {
          "name": "amount_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'held'"
        },
        "provider_started_at": {
          "name": "provider_started_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "settled_at": {
          "name": "settled_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "budget_reservations_fast_response_idx": {
          "name": "budget_reservations_fast_response_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "fast_response_request_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "budget_reservations_prompt_injection_idx": {
          "name": "budget_reservations_prompt_injection_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "prompt_injection_invocation_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "budget_reservations_decision_idx": {
          "name": "budget_reservations_decision_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "decision_invocation_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "budget_reservations_run_idx": {
          "name": "budget_reservations_run_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "budget_reservations_active_idx": {
          "name": "budget_reservations_active_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "project_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"budget_reservations\".\"state\" = 'held'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "budget_reservations_company_id_companies_id_fk": {
          "name": "budget_reservations_company_id_companies_id_fk",
          "tableFrom": "budget_reservations",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "budget_reservations_run_id_heartbeat_runs_id_fk": {
          "name": "budget_reservations_run_id_heartbeat_runs_id_fk",
          "tableFrom": "budget_reservations",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "budget_reservations_agent_id_agents_id_fk": {
          "name": "budget_reservations_agent_id_agents_id_fk",
          "tableFrom": "budget_reservations",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "budget_reservations_source_check": {
          "name": "budget_reservations_source_check",
          "value": "(\"budget_reservations\".\"run_id\" is not null)::int + (\"budget_reservations\".\"decision_invocation_id\" is not null)::int + (\"budget_reservations\".\"fast_response_request_id\" is not null)::int + (\"budget_reservations\".\"prompt_injection_invocation_id\" is not null)::int = 1"
        },
        "budget_reservations_state_check": {
          "name": "budget_reservations_state_check",
          "value": "\"budget_reservations\".\"state\" in ('held', 'settled', 'released')"
        },
        "budget_reservations_amount_check": {
          "name": "budget_reservations_amount_check",
          "value": "\"budget_reservations\".\"amount_cents\" >= 0"
        }
      },
      "isRLSEnabled": false
    },
    "public.cost_adjustments": {
      "name": "cost_adjustments",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "cost_event_id": {
          "name": "cost_event_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "invoice_line_id": {
          "name": "invoice_line_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "receipt_hash": {
          "name": "receipt_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "previous_cents": {
          "name": "previous_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true
        },
        "corrected_cents": {
          "name": "corrected_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true
        },
        "previous_status": {
          "name": "previous_status",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "previous_pricing": {
          "name": "previous_pricing",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "reason": {
          "name": "reason",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "actor_id": {
          "name": "actor_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "pricing": {
          "name": "pricing",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "cost_adjustments_receipt_idx": {
          "name": "cost_adjustments_receipt_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_adjustments_event_idx": {
          "name": "cost_adjustments_event_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "cost_event_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_adjustments_invoice_line_idx": {
          "name": "cost_adjustments_invoice_line_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "invoice_line_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "cost_adjustments_company_id_companies_id_fk": {
          "name": "cost_adjustments_company_id_companies_id_fk",
          "tableFrom": "cost_adjustments",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "cost_adjustments_cost_event_id_cost_events_id_fk": {
          "name": "cost_adjustments_cost_event_id_cost_events_id_fk",
          "tableFrom": "cost_adjustments",
          "tableTo": "cost_events",
          "columnsFrom": [
            "cost_event_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "cost_adjustments_invoice_line_id_billing_invoice_lines_id_fk": {
          "name": "cost_adjustments_invoice_line_id_billing_invoice_lines_id_fk",
          "tableFrom": "cost_adjustments",
          "tableTo": "billing_invoice_lines",
          "columnsFrom": [
            "invoice_line_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "cost_adjustments_amount_check": {
          "name": "cost_adjustments_amount_check",
          "value": "\"cost_adjustments\".\"previous_cents\" >= 0 and \"cost_adjustments\".\"corrected_cents\" >= 0"
        }
      },
      "isRLSEnabled": false
    },
    "public.provider_billing_snapshots": {
      "name": "provider_billing_snapshots",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "account_id": {
          "name": "account_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "scope_id": {
          "name": "scope_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "day": {
          "name": "day",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "amount_cents": {
          "name": "amount_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true
        },
        "revision": {
          "name": "revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "provider_billing_snapshots_identity_idx": {
          "name": "provider_billing_snapshots_identity_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "account_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "scope_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "day",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "provider_billing_snapshots_company_id_companies_id_fk": {
          "name": "provider_billing_snapshots_company_id_companies_id_fk",
          "tableFrom": "provider_billing_snapshots",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "provider_billing_snapshots_amount_check": {
          "name": "provider_billing_snapshots_amount_check",
          "value": "\"provider_billing_snapshots\".\"amount_cents\" >= 0"
        }
      },
      "isRLSEnabled": false
    },
    "public.run_usage_receipts": {
      "name": "run_usage_receipts",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_id": {
          "name": "source_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "sequence": {
          "name": "sequence",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "receipt_hash": {
          "name": "receipt_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "receipt_json": {
          "name": "receipt_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "complete": {
          "name": "complete",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true
        },
        "received_at": {
          "name": "received_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "run_usage_receipts_source_sequence_idx": {
          "name": "run_usage_receipts_source_sequence_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "sequence",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "run_usage_receipts_run_latest_idx": {
          "name": "run_usage_receipts_run_latest_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "received_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "run_usage_receipts_company_id_companies_id_fk": {
          "name": "run_usage_receipts_company_id_companies_id_fk",
          "tableFrom": "run_usage_receipts",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "run_usage_receipts_run_id_heartbeat_runs_id_fk": {
          "name": "run_usage_receipts_run_id_heartbeat_runs_id_fk",
          "tableFrom": "run_usage_receipts",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "run_usage_receipts_positive_sequence": {
          "name": "run_usage_receipts_positive_sequence",
          "value": "\"run_usage_receipts\".\"sequence\" > 0"
        }
      },
      "isRLSEnabled": false
    },
    "public.activity_log": {
      "name": "activity_log",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "actor_type": {
          "name": "actor_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'system'"
        },
        "actor_id": {
          "name": "actor_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "action": {
          "name": "action",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "entity_type": {
          "name": "entity_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "entity_id": {
          "name": "entity_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "details": {
          "name": "details",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "activity_log_company_created_idx": {
          "name": "activity_log_company_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "activity_log_company_agent_created_idx": {
          "name": "activity_log_company_agent_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "activity_log_company_responsible_user_created_idx": {
          "name": "activity_log_company_responsible_user_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "responsible_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "activity_log_run_id_idx": {
          "name": "activity_log_run_id_idx",
          "columns": [
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "activity_log_entity_type_id_idx": {
          "name": "activity_log_entity_type_id_idx",
          "columns": [
            {
              "expression": "entity_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "entity_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "activity_log_company_id_companies_id_fk": {
          "name": "activity_log_company_id_companies_id_fk",
          "tableFrom": "activity_log",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "activity_log_agent_id_agents_id_fk": {
          "name": "activity_log_agent_id_agents_id_fk",
          "tableFrom": "activity_log",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "activity_log_run_id_heartbeat_runs_id_fk": {
          "name": "activity_log_run_id_heartbeat_runs_id_fk",
          "tableFrom": "activity_log",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.adapter_auth_sessions": {
      "name": "adapter_auth_sessions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "environment_id": {
          "name": "environment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "ai_connection": {
          "name": "ai_connection",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "connection_grant_id": {
          "name": "connection_grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "connection_method": {
          "name": "connection_method",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "adapter_type": {
          "name": "adapter_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "started_by_user_id": {
          "name": "started_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "public_session_id": {
          "name": "public_session_id",
          "type": "varchar(128)",
          "primaryKey": false,
          "notNull": true
        },
        "provider_lease_id": {
          "name": "provider_lease_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'starting'"
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "promotion_expires_at": {
          "name": "promotion_expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "bound_at": {
          "name": "bound_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "finished_at": {
          "name": "finished_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "failure_reason": {
          "name": "failure_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "result_claim": {
          "name": "result_claim",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "adapter_auth_sessions_company_status_idx": {
          "name": "adapter_auth_sessions_company_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "adapter_auth_sessions_company_owner_adapter_active_uq": {
          "name": "adapter_auth_sessions_company_owner_adapter_active_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "started_by_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "adapter_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"adapter_auth_sessions\".\"status\" IN ('starting', 'waiting_for_user', 'promoting', 'awaiting_code', 'submitting')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "adapter_auth_sessions_public_session_id_uq": {
          "name": "adapter_auth_sessions_public_session_id_uq",
          "columns": [
            {
              "expression": "public_session_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "adapter_auth_sessions_environment_idx": {
          "name": "adapter_auth_sessions_environment_idx",
          "columns": [
            {
              "expression": "environment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "adapter_auth_sessions_expires_idx": {
          "name": "adapter_auth_sessions_expires_idx",
          "columns": [
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "adapter_auth_sessions_provider_lease_idx": {
          "name": "adapter_auth_sessions_provider_lease_idx",
          "columns": [
            {
              "expression": "provider_lease_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "adapter_auth_sessions_company_id_companies_id_fk": {
          "name": "adapter_auth_sessions_company_id_companies_id_fk",
          "tableFrom": "adapter_auth_sessions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "adapter_auth_sessions_environment_id_environments_id_fk": {
          "name": "adapter_auth_sessions_environment_id_environments_id_fk",
          "tableFrom": "adapter_auth_sessions",
          "tableTo": "environments",
          "columnsFrom": [
            "environment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.agent_api_keys": {
      "name": "agent_api_keys",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "key_hash": {
          "name": "key_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "scope_config": {
          "name": "scope_config",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "last_used_at": {
          "name": "last_used_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "revoked_at": {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "agent_api_keys_key_hash_idx": {
          "name": "agent_api_keys_key_hash_idx",
          "columns": [
            {
              "expression": "key_hash",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_api_keys_company_agent_idx": {
          "name": "agent_api_keys_company_agent_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "agent_api_keys_agent_id_agents_id_fk": {
          "name": "agent_api_keys_agent_id_agents_id_fk",
          "tableFrom": "agent_api_keys",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "agent_api_keys_company_id_companies_id_fk": {
          "name": "agent_api_keys_company_id_companies_id_fk",
          "tableFrom": "agent_api_keys",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.agent_commentary": {
      "name": "agent_commentary",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "body": {
          "name": "body",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "payload_hash": {
          "name": "payload_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "agent_commentary_run_key_uq": {
          "name": "agent_commentary_run_key_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_commentary_company_kind_created_idx": {
          "name": "agent_commentary_company_kind_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "agent_commentary_company_id_companies_id_fk": {
          "name": "agent_commentary_company_id_companies_id_fk",
          "tableFrom": "agent_commentary",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_commentary_agent_id_agents_id_fk": {
          "name": "agent_commentary_agent_id_agents_id_fk",
          "tableFrom": "agent_commentary",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_commentary_run_id_heartbeat_runs_id_fk": {
          "name": "agent_commentary_run_id_heartbeat_runs_id_fk",
          "tableFrom": "agent_commentary",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_commentary_issue_id_issues_id_fk": {
          "name": "agent_commentary_issue_id_issues_id_fk",
          "tableFrom": "agent_commentary",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "agent_commentary_kind_check": {
          "name": "agent_commentary_kind_check",
          "value": "\"agent_commentary\".\"kind\" in ('complaint', 'suggestion')"
        }
      },
      "isRLSEnabled": false
    },
    "public.agent_config_revisions": {
      "name": "agent_config_revisions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "source": {
          "name": "source",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'patch'"
        },
        "rolled_back_from_revision_id": {
          "name": "rolled_back_from_revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "changed_keys": {
          "name": "changed_keys",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "before_config": {
          "name": "before_config",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "after_config": {
          "name": "after_config",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "agent_config_revisions_company_agent_created_idx": {
          "name": "agent_config_revisions_company_agent_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_config_revisions_agent_created_idx": {
          "name": "agent_config_revisions_agent_created_idx",
          "columns": [
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "agent_config_revisions_company_id_companies_id_fk": {
          "name": "agent_config_revisions_company_id_companies_id_fk",
          "tableFrom": "agent_config_revisions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "agent_config_revisions_agent_id_agents_id_fk": {
          "name": "agent_config_revisions_agent_id_agents_id_fk",
          "tableFrom": "agent_config_revisions",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_config_revisions_created_by_agent_id_agents_id_fk": {
          "name": "agent_config_revisions_created_by_agent_id_agents_id_fk",
          "tableFrom": "agent_config_revisions",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.agent_identity_keys": {
      "name": "agent_identity_keys",
      "schema": "",
      "columns": {
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "algorithm": {
          "name": "algorithm",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "key_id": {
          "name": "key_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "public_key_pem": {
          "name": "public_key_pem",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "private_key_material": {
          "name": "private_key_material",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "agent_identity_keys_owner_fk": {
          "name": "agent_identity_keys_owner_fk",
          "tableFrom": "agent_identity_keys",
          "tableTo": "agents",
          "columnsFrom": [
            "company_id",
            "agent_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "agent_identity_keys_algorithm_check": {
          "name": "agent_identity_keys_algorithm_check",
          "value": "\"agent_identity_keys\".\"algorithm\" = 'Ed25519'"
        }
      },
      "isRLSEnabled": false
    },
    "public.agent_instruction_heads": {
      "name": "agent_instruction_heads",
      "schema": "",
      "columns": {
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "entry_file": {
          "name": "entry_file",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "revision_id": {
          "name": "revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "agent_instruction_heads_company_id_agent_id_entry_file_revision_id_agent_instruction_revisions_company_id_agent_id_entry_file_id_fk": {
          "name": "agent_instruction_heads_company_id_agent_id_entry_file_revision_id_agent_instruction_revisions_company_id_agent_id_entry_file_id_fk",
          "tableFrom": "agent_instruction_heads",
          "tableTo": "agent_instruction_revisions",
          "columnsFrom": [
            "company_id",
            "agent_id",
            "entry_file",
            "revision_id"
          ],
          "columnsTo": [
            "company_id",
            "agent_id",
            "entry_file",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "agent_instruction_heads_identity_uq": {
          "name": "agent_instruction_heads_identity_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "agent_id",
            "entry_file"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.agent_instruction_revisions": {
      "name": "agent_instruction_revisions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "entry_file": {
          "name": "entry_file",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "content_base64": {
          "name": "content_base64",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "content_hash": {
          "name": "content_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "byte_length": {
          "name": "byte_length",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "parent_revision_id": {
          "name": "parent_revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "base_revision_id": {
          "name": "base_revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "restored_from_revision_id": {
          "name": "restored_from_revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "actor_agent_id": {
          "name": "actor_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "actor_user_id": {
          "name": "actor_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "source_run_id": {
          "name": "source_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "source": {
          "name": "source",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "agent_instruction_revisions_history_idx": {
          "name": "agent_instruction_revisions_history_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "entry_file",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "agent_instruction_revisions_company_id_agent_id_agents_company_id_id_fk": {
          "name": "agent_instruction_revisions_company_id_agent_id_agents_company_id_id_fk",
          "tableFrom": "agent_instruction_revisions",
          "tableTo": "agents",
          "columnsFrom": [
            "company_id",
            "agent_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "agent_instruction_revisions_identity_uq": {
          "name": "agent_instruction_revisions_identity_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "agent_id",
            "entry_file",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.agent_instruction_working_copies": {
      "name": "agent_instruction_working_copies",
      "schema": "",
      "columns": {
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "entry_file": {
          "name": "entry_file",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "base_revision_id": {
          "name": "base_revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "base_hash": {
          "name": "base_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "local_root": {
          "name": "local_root",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "execution_root": {
          "name": "execution_root",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "location": {
          "name": "location",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'prepared'"
        },
        "candidate_base64": {
          "name": "candidate_base64",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "candidate_hash": {
          "name": "candidate_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "error_code": {
          "name": "error_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "error_message": {
          "name": "error_message",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "receipt": {
          "name": "receipt",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "process_stopped_at": {
          "name": "process_stopped_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "attempts": {
          "name": "attempts",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "next_attempt_at": {
          "name": "next_attempt_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "agent_instruction_copies_pending_idx": {
          "name": "agent_instruction_copies_pending_idx",
          "columns": [
            {
              "expression": "state",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "next_attempt_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_instruction_copies_agent_idx": {
          "name": "agent_instruction_copies_agent_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "agent_instruction_working_copies_run_id_heartbeat_runs_id_fk": {
          "name": "agent_instruction_working_copies_run_id_heartbeat_runs_id_fk",
          "tableFrom": "agent_instruction_working_copies",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_instruction_working_copies_company_id_agent_id_agents_company_id_id_fk": {
          "name": "agent_instruction_working_copies_company_id_agent_id_agents_company_id_id_fk",
          "tableFrom": "agent_instruction_working_copies",
          "tableTo": "agents",
          "columnsFrom": [
            "company_id",
            "agent_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.agent_memberships": {
      "name": "agent_memberships",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'joined'"
        },
        "starred_at": {
          "name": "starred_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "agent_memberships_company_user_idx": {
          "name": "agent_memberships_company_user_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_memberships_company_user_starred_idx": {
          "name": "agent_memberships_company_user_starred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "starred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_memberships_agent_idx": {
          "name": "agent_memberships_agent_idx",
          "columns": [
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_memberships_company_user_agent_uq": {
          "name": "agent_memberships_company_user_agent_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "agent_memberships_company_id_companies_id_fk": {
          "name": "agent_memberships_company_id_companies_id_fk",
          "tableFrom": "agent_memberships",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_memberships_agent_id_agents_id_fk": {
          "name": "agent_memberships_agent_id_agents_id_fk",
          "tableFrom": "agent_memberships",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.agent_runtime_state": {
      "name": "agent_runtime_state",
      "schema": "",
      "columns": {
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "adapter_type": {
          "name": "adapter_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "session_id": {
          "name": "session_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "state_json": {
          "name": "state_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "last_run_id": {
          "name": "last_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "last_run_status": {
          "name": "last_run_status",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "total_input_tokens": {
          "name": "total_input_tokens",
          "type": "bigint",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "total_output_tokens": {
          "name": "total_output_tokens",
          "type": "bigint",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "total_cached_input_tokens": {
          "name": "total_cached_input_tokens",
          "type": "bigint",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "total_cost_cents": {
          "name": "total_cost_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "last_error": {
          "name": "last_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "agent_runtime_state_company_agent_idx": {
          "name": "agent_runtime_state_company_agent_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_runtime_state_company_updated_idx": {
          "name": "agent_runtime_state_company_updated_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "updated_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "agent_runtime_state_agent_id_agents_id_fk": {
          "name": "agent_runtime_state_agent_id_agents_id_fk",
          "tableFrom": "agent_runtime_state",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "agent_runtime_state_company_id_companies_id_fk": {
          "name": "agent_runtime_state_company_id_companies_id_fk",
          "tableFrom": "agent_runtime_state",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.agent_session_goal_actions": {
      "name": "agent_session_goal_actions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "session_id": {
          "name": "session_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "request_id": {
          "name": "request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "action": {
          "name": "action",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "payload_json": {
          "name": "payload_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "result_json": {
          "name": "result_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "error": {
          "name": "error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "delivered_at": {
          "name": "delivered_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "completed_at": {
          "name": "completed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "agent_session_goal_actions_session_request_uniq": {
          "name": "agent_session_goal_actions_session_request_uniq",
          "columns": [
            {
              "expression": "session_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "request_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_session_goal_actions_company_status_created_idx": {
          "name": "agent_session_goal_actions_company_status_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_session_goal_actions_session_created_idx": {
          "name": "agent_session_goal_actions_session_created_idx",
          "columns": [
            {
              "expression": "session_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "agent_session_goal_actions_company_id_companies_id_fk": {
          "name": "agent_session_goal_actions_company_id_companies_id_fk",
          "tableFrom": "agent_session_goal_actions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "agent_session_goal_actions_session_id_agent_task_sessions_id_fk": {
          "name": "agent_session_goal_actions_session_id_agent_task_sessions_id_fk",
          "tableFrom": "agent_session_goal_actions",
          "tableTo": "agent_task_sessions",
          "columnsFrom": [
            "session_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.agent_task_sessions": {
      "name": "agent_task_sessions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "adapter_type": {
          "name": "adapter_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "task_key": {
          "name": "task_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "session_params_json": {
          "name": "session_params_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "session_display_id": {
          "name": "session_display_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "last_run_id": {
          "name": "last_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "last_error": {
          "name": "last_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "goal_capability_json": {
          "name": "goal_capability_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "goal_json": {
          "name": "goal_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "goal_status": {
          "name": "goal_status",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "goal_desired_state": {
          "name": "goal_desired_state",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "goal_source_id": {
          "name": "goal_source_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "goal_source_cursor": {
          "name": "goal_source_cursor",
          "type": "bigint",
          "primaryKey": false,
          "notNull": false
        },
        "goal_revision": {
          "name": "goal_revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "goal_observed_at": {
          "name": "goal_observed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "agent_task_sessions_company_agent_adapter_task_uniq": {
          "name": "agent_task_sessions_company_agent_adapter_task_uniq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "adapter_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "task_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_task_sessions_company_agent_updated_idx": {
          "name": "agent_task_sessions_company_agent_updated_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "updated_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_task_sessions_company_task_updated_idx": {
          "name": "agent_task_sessions_company_task_updated_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "task_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "updated_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "agent_task_sessions_company_id_companies_id_fk": {
          "name": "agent_task_sessions_company_id_companies_id_fk",
          "tableFrom": "agent_task_sessions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "agent_task_sessions_agent_id_agents_id_fk": {
          "name": "agent_task_sessions_agent_id_agents_id_fk",
          "tableFrom": "agent_task_sessions",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "agent_task_sessions_last_run_id_heartbeat_runs_id_fk": {
          "name": "agent_task_sessions_last_run_id_heartbeat_runs_id_fk",
          "tableFrom": "agent_task_sessions",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "last_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.agent_wakeup_requests": {
      "name": "agent_wakeup_requests",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source": {
          "name": "source",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "trigger_detail": {
          "name": "trigger_detail",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "reason": {
          "name": "reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "payload": {
          "name": "payload",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'queued'"
        },
        "coalesced_count": {
          "name": "coalesced_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "requested_by_actor_type": {
          "name": "requested_by_actor_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "requested_by_actor_id": {
          "name": "requested_by_actor_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "requested_at": {
          "name": "requested_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "claimed_at": {
          "name": "claimed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "finished_at": {
          "name": "finished_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "error": {
          "name": "error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "agent_wakeup_requests_task_retry_idempotency_uq": {
          "name": "agent_wakeup_requests_task_retry_idempotency_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'task-retry:%'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_wakeup_requests_company_agent_status_idx": {
          "name": "agent_wakeup_requests_company_agent_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_wakeup_requests_company_requested_idx": {
          "name": "agent_wakeup_requests_company_requested_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "requested_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_wakeup_requests_agent_requested_idx": {
          "name": "agent_wakeup_requests_agent_requested_idx",
          "columns": [
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "requested_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_wakeup_requests_review_path_recovery_idempotency_uq": {
          "name": "agent_wakeup_requests_review_path_recovery_idempotency_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'issue_review_path_lost:%' AND \"agent_wakeup_requests\".\"status\" <> 'skipped'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_wakeup_requests_disposition_repair_idempotency_uq": {
          "name": "agent_wakeup_requests_disposition_repair_idempotency_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'issue_disposition_repair:%' AND \"agent_wakeup_requests\".\"status\" <> 'skipped'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_wakeup_requests_question_response_delivery_idempotency_uq": {
          "name": "agent_wakeup_requests_question_response_delivery_idempotency_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "(\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'question-response:%' OR \"agent_wakeup_requests\".\"idempotency_key\" LIKE 'interaction:%') AND \"agent_wakeup_requests\".\"status\" NOT IN ('skipped', 'failed', 'cancelled')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_wakeup_requests_question_response_history_idx": {
          "name": "agent_wakeup_requests_question_response_history_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'question-response:%'",
          "concurrently": true,
          "method": "btree",
          "with": {}
        },
        "agent_wakeup_requests_connection_intent_delivery_idempotency_uq": {
          "name": "agent_wakeup_requests_connection_intent_delivery_idempotency_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'connection-intent:%' AND \"agent_wakeup_requests\".\"status\" NOT IN ('skipped', 'failed', 'cancelled')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_wakeup_requests_tool_action_delivery_uq": {
          "name": "agent_wakeup_requests_tool_action_delivery_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'tool-action-response:%' AND \"agent_wakeup_requests\".\"status\" NOT IN ('skipped', 'failed', 'cancelled')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_wakeup_requests_chat_completion_uq": {
          "name": "agent_wakeup_requests_chat_completion_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'chat-completion:%'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agent_wakeup_requests_company_payload_issue_idx": {
          "name": "agent_wakeup_requests_company_payload_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "(\"payload\" ->> 'issueId')",
              "asc": true,
              "isExpression": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "agent_wakeup_requests_company_id_companies_id_fk": {
          "name": "agent_wakeup_requests_company_id_companies_id_fk",
          "tableFrom": "agent_wakeup_requests",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "agent_wakeup_requests_agent_id_agents_id_fk": {
          "name": "agent_wakeup_requests_agent_id_agents_id_fk",
          "tableFrom": "agent_wakeup_requests",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.agents": {
      "name": "agents",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "role": {
          "name": "role",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'general'"
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "icon": {
          "name": "icon",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "appearance": {
          "name": "appearance",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'idle'"
        },
        "lifecycle_state": {
          "name": "lifecycle_state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'ready'"
        },
        "lifecycle_required_plugin_ids": {
          "name": "lifecycle_required_plugin_ids",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "lifecycle_holds": {
          "name": "lifecycle_holds",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "lifecycle_version": {
          "name": "lifecycle_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "lifecycle_error": {
          "name": "lifecycle_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "lifecycle_operation": {
          "name": "lifecycle_operation",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "reports_to": {
          "name": "reports_to",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "capabilities": {
          "name": "capabilities",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "adapter_type": {
          "name": "adapter_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'process'"
        },
        "adapter_config": {
          "name": "adapter_config",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "runtime_config": {
          "name": "runtime_config",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "default_environment_id": {
          "name": "default_environment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "budget_monthly_cents": {
          "name": "budget_monthly_cents",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "spend_month_utc": {
          "name": "spend_month_utc",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "spent_monthly_cents": {
          "name": "spent_monthly_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "pause_reason": {
          "name": "pause_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "paused_at": {
          "name": "paused_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "error_reason": {
          "name": "error_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "permissions": {
          "name": "permissions",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "last_heartbeat_at": {
          "name": "last_heartbeat_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "agents_lifecycle_work_idx": {
          "name": "agents_lifecycle_work_idx",
          "columns": [
            {
              "expression": "lifecycle_state",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "updated_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agents_company_status_idx": {
          "name": "agents_company_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agents_company_reports_to_idx": {
          "name": "agents_company_reports_to_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "reports_to",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "agents_company_default_environment_idx": {
          "name": "agents_company_default_environment_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "default_environment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "agents_company_id_companies_id_fk": {
          "name": "agents_company_id_companies_id_fk",
          "tableFrom": "agents",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "agents_reports_to_agents_id_fk": {
          "name": "agents_reports_to_agents_id_fk",
          "tableFrom": "agents",
          "tableTo": "agents",
          "columnsFrom": [
            "reports_to"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "agents_default_environment_id_environments_id_fk": {
          "name": "agents_default_environment_id_environments_id_fk",
          "tableFrom": "agents",
          "tableTo": "environments",
          "columnsFrom": [
            "default_environment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "agents_company_id_uq": {
          "name": "agents_company_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.ai_connection_defaults": {
      "name": "ai_connection_defaults",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "method": {
          "name": "method",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "ai_connection_defaults_owner_method_uq": {
          "name": "ai_connection_defaults_owner_method_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "method",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "ai_connection_defaults_company_id_companies_id_fk": {
          "name": "ai_connection_defaults_company_id_companies_id_fk",
          "tableFrom": "ai_connection_defaults",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_connection_defaults_company_grant_fk": {
          "name": "ai_connection_defaults_company_grant_fk",
          "tableFrom": "ai_connection_defaults",
          "tableTo": "connection_grants",
          "columnsFrom": [
            "company_id",
            "grant_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "ai_connection_defaults_provider_check": {
          "name": "ai_connection_defaults_provider_check",
          "value": "\"ai_connection_defaults\".\"provider\" in ('anthropic','openai','openrouter','xai','google','github')"
        },
        "ai_connection_defaults_method_check": {
          "name": "ai_connection_defaults_method_check",
          "value": "\"ai_connection_defaults\".\"method\" in ('subscription','api_key')"
        }
      },
      "isRLSEnabled": false
    },
    "public.ai_connection_pools": {
      "name": "ai_connection_pools",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "plugin_key": {
          "name": "plugin_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "config": {
          "name": "config",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "revision": {
          "name": "revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "ai_connection_pools_id_tool_connections_id_fk": {
          "name": "ai_connection_pools_id_tool_connections_id_fk",
          "tableFrom": "ai_connection_pools",
          "tableTo": "tool_connections",
          "columnsFrom": [
            "id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_connection_pools_company_id_companies_id_fk": {
          "name": "ai_connection_pools_company_id_companies_id_fk",
          "tableFrom": "ai_connection_pools",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_connection_pools_company_connection_fk": {
          "name": "ai_connection_pools_company_connection_fk",
          "tableFrom": "ai_connection_pools",
          "tableTo": "tool_connections",
          "columnsFrom": [
            "company_id",
            "id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "ai_connection_pools_company_id_uq": {
          "name": "ai_connection_pools_company_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.ai_connection_router_cursors": {
      "name": "ai_connection_router_cursors",
      "schema": "",
      "columns": {
        "pool_id": {
          "name": "pool_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "last_member_id": {
          "name": "last_member_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "version": {
          "name": "version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        }
      },
      "indexes": {},
      "foreignKeys": {
        "ai_connection_router_cursors_pool_id_ai_connection_pools_id_fk": {
          "name": "ai_connection_router_cursors_pool_id_ai_connection_pools_id_fk",
          "tableFrom": "ai_connection_router_cursors",
          "tableTo": "ai_connection_pools",
          "columnsFrom": [
            "pool_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_connection_router_cursors_company_id_companies_id_fk": {
          "name": "ai_connection_router_cursors_company_id_companies_id_fk",
          "tableFrom": "ai_connection_router_cursors",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_connection_router_cursors_company_pool_fk": {
          "name": "ai_connection_router_cursors_company_pool_fk",
          "tableFrom": "ai_connection_router_cursors",
          "tableTo": "ai_connection_pools",
          "columnsFrom": [
            "company_id",
            "pool_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.ai_connection_task_pins": {
      "name": "ai_connection_task_pins",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "pool_id": {
          "name": "pool_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "task_key": {
          "name": "task_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "selection": {
          "name": "selection",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "member": {
          "name": "member",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "ai_connection_task_pins_affinity_uq": {
          "name": "ai_connection_task_pins_affinity_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "pool_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "task_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "ai_connection_task_pins_company_id_companies_id_fk": {
          "name": "ai_connection_task_pins_company_id_companies_id_fk",
          "tableFrom": "ai_connection_task_pins",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_connection_task_pins_pool_id_ai_connection_pools_id_fk": {
          "name": "ai_connection_task_pins_pool_id_ai_connection_pools_id_fk",
          "tableFrom": "ai_connection_task_pins",
          "tableTo": "ai_connection_pools",
          "columnsFrom": [
            "pool_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_connection_task_pins_agent_id_agents_id_fk": {
          "name": "ai_connection_task_pins_agent_id_agents_id_fk",
          "tableFrom": "ai_connection_task_pins",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_connection_task_pins_company_pool_fk": {
          "name": "ai_connection_task_pins_company_pool_fk",
          "tableFrom": "ai_connection_task_pins",
          "tableTo": "ai_connection_pools",
          "columnsFrom": [
            "company_id",
            "pool_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_connection_task_pins_company_agent_fk": {
          "name": "ai_connection_task_pins_company_agent_fk",
          "tableFrom": "ai_connection_task_pins",
          "tableTo": "agents",
          "columnsFrom": [
            "company_id",
            "agent_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.ai_provider_defaults": {
      "name": "ai_provider_defaults",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "ai_provider_defaults_owner_provider_uq": {
          "name": "ai_provider_defaults_owner_provider_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "ai_provider_defaults_company_id_companies_id_fk": {
          "name": "ai_provider_defaults_company_id_companies_id_fk",
          "tableFrom": "ai_provider_defaults",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_provider_defaults_company_grant_fk": {
          "name": "ai_provider_defaults_company_grant_fk",
          "tableFrom": "ai_provider_defaults",
          "tableTo": "connection_grants",
          "columnsFrom": [
            "company_id",
            "grant_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "ai_provider_defaults_provider_check": {
          "name": "ai_provider_defaults_provider_check",
          "value": "\"ai_provider_defaults\".\"provider\" in ('anthropic','openai','openrouter','xai','google','github')"
        }
      },
      "isRLSEnabled": false
    },
    "public.ai_subscription_connections": {
      "name": "ai_subscription_connections",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "credential_key": {
          "name": "credential_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "subscription_id": {
          "name": "subscription_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        }
      },
      "indexes": {
        "ai_subscription_connections_grant_idx": {
          "name": "ai_subscription_connections_grant_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "grant_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "ai_subscription_connections_credential_idx": {
          "name": "ai_subscription_connections_credential_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "credential_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "ai_subscription_connections_account_idx": {
          "name": "ai_subscription_connections_account_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "subscription_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "ai_subscription_connections_company_id_companies_id_fk": {
          "name": "ai_subscription_connections_company_id_companies_id_fk",
          "tableFrom": "ai_subscription_connections",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_subscription_connections_connection_id_tool_connections_id_fk": {
          "name": "ai_subscription_connections_connection_id_tool_connections_id_fk",
          "tableFrom": "ai_subscription_connections",
          "tableTo": "tool_connections",
          "columnsFrom": [
            "connection_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_subscription_connections_grant_id_connection_grants_id_fk": {
          "name": "ai_subscription_connections_grant_id_connection_grants_id_fk",
          "tableFrom": "ai_subscription_connections",
          "tableTo": "connection_grants",
          "columnsFrom": [
            "grant_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_subscription_connections_subscription_id_ai_subscriptions_id_fk": {
          "name": "ai_subscription_connections_subscription_id_ai_subscriptions_id_fk",
          "tableFrom": "ai_subscription_connections",
          "tableTo": "ai_subscriptions",
          "columnsFrom": [
            "subscription_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.ai_subscription_prices": {
      "name": "ai_subscription_prices",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "subscription_id": {
          "name": "subscription_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "revision": {
          "name": "revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "plan": {
          "name": "plan",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "amount_cents": {
          "name": "amount_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": false
        },
        "currency": {
          "name": "currency",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'USD'"
        },
        "cadence": {
          "name": "cadence",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'month'"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "source": {
          "name": "source",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_url": {
          "name": "source_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "effective_at": {
          "name": "effective_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "ai_subscription_prices_revision_idx": {
          "name": "ai_subscription_prices_revision_idx",
          "columns": [
            {
              "expression": "subscription_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "revision",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "ai_subscription_prices_company_idx": {
          "name": "ai_subscription_prices_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "ai_subscription_prices_company_id_companies_id_fk": {
          "name": "ai_subscription_prices_company_id_companies_id_fk",
          "tableFrom": "ai_subscription_prices",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_subscription_prices_subscription_id_ai_subscriptions_id_fk": {
          "name": "ai_subscription_prices_subscription_id_ai_subscriptions_id_fk",
          "tableFrom": "ai_subscription_prices",
          "tableTo": "ai_subscriptions",
          "columnsFrom": [
            "subscription_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "ai_subscription_prices_valid": {
          "name": "ai_subscription_prices_valid",
          "value": "(\"ai_subscription_prices\".\"amount_cents\" is null or \"ai_subscription_prices\".\"amount_cents\" >= 0) and \"ai_subscription_prices\".\"cadence\" in ('month','year') and \"ai_subscription_prices\".\"status\" in ('active','ended','excluded') and \"ai_subscription_prices\".\"source\" in ('catalog','user','unknown')"
        }
      },
      "isRLSEnabled": false
    },
    "public.ai_subscriptions": {
      "name": "ai_subscriptions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "account_key": {
          "name": "account_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "identity_verified": {
          "name": "identity_verified",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "owner_user_ids": {
          "name": "owner_user_ids",
          "type": "text[]",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::text[]"
        },
        "shared": {
          "name": "shared",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "detected_plan": {
          "name": "detected_plan",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "observed_at": {
          "name": "observed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_checked_at": {
          "name": "last_checked_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "refresh_status": {
          "name": "refresh_status",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "merged_into_id": {
          "name": "merged_into_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "revision": {
          "name": "revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "ai_subscriptions_identity_idx": {
          "name": "ai_subscriptions_identity_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "account_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "ai_subscriptions_company_idx": {
          "name": "ai_subscriptions_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "ai_subscriptions_company_id_companies_id_fk": {
          "name": "ai_subscriptions_company_id_companies_id_fk",
          "tableFrom": "ai_subscriptions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "ai_subscriptions_merged_into_id_ai_subscriptions_id_fk": {
          "name": "ai_subscriptions_merged_into_id_ai_subscriptions_id_fk",
          "tableFrom": "ai_subscriptions",
          "tableTo": "ai_subscriptions",
          "columnsFrom": [
            "merged_into_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "ai_subscriptions_no_self_merge": {
          "name": "ai_subscriptions_no_self_merge",
          "value": "\"ai_subscriptions\".\"merged_into_id\" is null or \"ai_subscriptions\".\"merged_into_id\" <> \"ai_subscriptions\".\"id\""
        }
      },
      "isRLSEnabled": false
    },
    "public.announcement_dismissals": {
      "name": "announcement_dismissals",
      "schema": "",
      "columns": {
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "announcement_id": {
          "name": "announcement_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "dismissed_at": {
          "name": "dismissed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {
        "announcement_dismissals_user_id_announcement_id_pk": {
          "name": "announcement_dismissals_user_id_announcement_id_pk",
          "columns": [
            "user_id",
            "announcement_id"
          ]
        }
      },
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.announcement_publications": {
      "name": "announcement_publications",
      "schema": "",
      "columns": {
        "announcement_id": {
          "name": "announcement_id",
          "type": "text",
          "primaryKey": true,
          "notNull": true
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.approval_comments": {
      "name": "approval_comments",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "approval_id": {
          "name": "approval_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "author_agent_id": {
          "name": "author_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "author_user_id": {
          "name": "author_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "body": {
          "name": "body",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "approval_comments_company_idx": {
          "name": "approval_comments_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "approval_comments_approval_idx": {
          "name": "approval_comments_approval_idx",
          "columns": [
            {
              "expression": "approval_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "approval_comments_approval_created_idx": {
          "name": "approval_comments_approval_created_idx",
          "columns": [
            {
              "expression": "approval_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "approval_comments_company_id_companies_id_fk": {
          "name": "approval_comments_company_id_companies_id_fk",
          "tableFrom": "approval_comments",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "approval_comments_approval_id_approvals_id_fk": {
          "name": "approval_comments_approval_id_approvals_id_fk",
          "tableFrom": "approval_comments",
          "tableTo": "approvals",
          "columnsFrom": [
            "approval_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "approval_comments_author_agent_id_agents_id_fk": {
          "name": "approval_comments_author_agent_id_agents_id_fk",
          "tableFrom": "approval_comments",
          "tableTo": "agents",
          "columnsFrom": [
            "author_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.approvals": {
      "name": "approvals",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "type": {
          "name": "type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "requested_by_agent_id": {
          "name": "requested_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "requested_by_user_id": {
          "name": "requested_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "payload": {
          "name": "payload",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "decision_note": {
          "name": "decision_note",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "decided_by_user_id": {
          "name": "decided_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "decided_at": {
          "name": "decided_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "approvals_company_status_type_idx": {
          "name": "approvals_company_status_type_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "approvals_company_id_companies_id_fk": {
          "name": "approvals_company_id_companies_id_fk",
          "tableFrom": "approvals",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "approvals_requested_by_agent_id_agents_id_fk": {
          "name": "approvals_requested_by_agent_id_agents_id_fk",
          "tableFrom": "approvals",
          "tableTo": "agents",
          "columnsFrom": [
            "requested_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.assets": {
      "name": "assets",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "object_key": {
          "name": "object_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "content_type": {
          "name": "content_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "byte_size": {
          "name": "byte_size",
          "type": "bigint",
          "primaryKey": false,
          "notNull": true
        },
        "sha256": {
          "name": "sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "original_filename": {
          "name": "original_filename",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "assets_company_created_idx": {
          "name": "assets_company_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "assets_company_provider_idx": {
          "name": "assets_company_provider_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "assets_company_object_key_uq": {
          "name": "assets_company_object_key_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "object_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "assets_company_id_companies_id_fk": {
          "name": "assets_company_id_companies_id_fk",
          "tableFrom": "assets",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "assets_created_by_agent_id_agents_id_fk": {
          "name": "assets_created_by_agent_id_agents_id_fk",
          "tableFrom": "assets",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.account": {
      "name": "account",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true
        },
        "issuer": {
          "name": "issuer",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "account_id": {
          "name": "account_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider_id": {
          "name": "provider_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "access_token": {
          "name": "access_token",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "refresh_token": {
          "name": "refresh_token",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "id_token": {
          "name": "id_token",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "access_token_expires_at": {
          "name": "access_token_expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "refresh_token_expires_at": {
          "name": "refresh_token_expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "scope": {
          "name": "scope",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "password": {
          "name": "password",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        }
      },
      "indexes": {
        "account_issuer_account_id_uq": {
          "name": "account_issuer_account_id_uq",
          "columns": [
            {
              "expression": "issuer",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "account_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "account_user_id_user_id_fk": {
          "name": "account_user_id_user_id_fk",
          "tableFrom": "account",
          "tableTo": "user",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.session": {
      "name": "session",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "token": {
          "name": "token",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "ip_address": {
          "name": "ip_address",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "user_agent": {
          "name": "user_agent",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        }
      },
      "indexes": {},
      "foreignKeys": {
        "session_user_id_user_id_fk": {
          "name": "session_user_id_user_id_fk",
          "tableFrom": "session",
          "tableTo": "user",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.user": {
      "name": "user",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "email": {
          "name": "email",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "email_verified": {
          "name": "email_verified",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "image": {
          "name": "image",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.verification": {
      "name": "verification",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true
        },
        "identifier": {
          "name": "identifier",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "value": {
          "name": "value",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.board_api_keys": {
      "name": "board_api_keys",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "key_hash": {
          "name": "key_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "last_used_at": {
          "name": "last_used_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "revoked_at": {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "board_api_keys_key_hash_idx": {
          "name": "board_api_keys_key_hash_idx",
          "columns": [
            {
              "expression": "key_hash",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "board_api_keys_user_idx": {
          "name": "board_api_keys_user_idx",
          "columns": [
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "board_api_keys_user_id_user_id_fk": {
          "name": "board_api_keys_user_id_user_id_fk",
          "tableFrom": "board_api_keys",
          "tableTo": "user",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.browser_use_browsers": {
      "name": "browser_use_browsers",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "session_id": {
          "name": "session_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider_browser_id": {
          "name": "provider_browser_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "browser_use_browsers_provider_uq": {
          "name": "browser_use_browsers_provider_uq",
          "columns": [
            {
              "expression": "provider_browser_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "browser_use_browsers_session_idx": {
          "name": "browser_use_browsers_session_idx",
          "columns": [
            {
              "expression": "session_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "browser_use_browsers_company_id_companies_id_fk": {
          "name": "browser_use_browsers_company_id_companies_id_fk",
          "tableFrom": "browser_use_browsers",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "browser_use_browsers_session_id_browser_use_sessions_id_fk": {
          "name": "browser_use_browsers_session_id_browser_use_sessions_id_fk",
          "tableFrom": "browser_use_browsers",
          "tableTo": "browser_use_sessions",
          "columnsFrom": [
            "session_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.browser_use_runs": {
      "name": "browser_use_runs",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "session_id": {
          "name": "session_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "heartbeat_run_id": {
          "name": "heartbeat_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "invocation_id": {
          "name": "invocation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider_run_id": {
          "name": "provider_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "recovery_cursor": {
          "name": "recovery_cursor",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'creating'"
        },
        "detached_until": {
          "name": "detached_until",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "event_cursor": {
          "name": "event_cursor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "events_drained": {
          "name": "events_drained",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "accounted_cents": {
          "name": "accounted_cents",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "progress": {
          "name": "progress",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "result": {
          "name": "result",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "browser_use_runs_invocation_uq": {
          "name": "browser_use_runs_invocation_uq",
          "columns": [
            {
              "expression": "invocation_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "browser_use_runs_provider_uq": {
          "name": "browser_use_runs_provider_uq",
          "columns": [
            {
              "expression": "provider_run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "browser_use_runs_session_idx": {
          "name": "browser_use_runs_session_idx",
          "columns": [
            {
              "expression": "session_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "browser_use_runs_company_id_companies_id_fk": {
          "name": "browser_use_runs_company_id_companies_id_fk",
          "tableFrom": "browser_use_runs",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "browser_use_runs_session_id_browser_use_sessions_id_fk": {
          "name": "browser_use_runs_session_id_browser_use_sessions_id_fk",
          "tableFrom": "browser_use_runs",
          "tableTo": "browser_use_sessions",
          "columnsFrom": [
            "session_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "browser_use_runs_heartbeat_run_id_heartbeat_runs_id_fk": {
          "name": "browser_use_runs_heartbeat_run_id_heartbeat_runs_id_fk",
          "tableFrom": "browser_use_runs",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "heartbeat_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.browser_use_sessions": {
      "name": "browser_use_sessions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider_session_id": {
          "name": "provider_session_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'starting'"
        },
        "idle_deadline": {
          "name": "idle_deadline",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "stop_requested": {
          "name": "stop_requested",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "error": {
          "name": "error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "lease_token": {
          "name": "lease_token",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "lease_until": {
          "name": "lease_until",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "next_poll_at": {
          "name": "next_poll_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "browser_use_sessions_task_idx": {
          "name": "browser_use_sessions_task_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "browser_use_sessions_provider_uq": {
          "name": "browser_use_sessions_provider_uq",
          "columns": [
            {
              "expression": "provider_session_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "browser_use_sessions_company_id_companies_id_fk": {
          "name": "browser_use_sessions_company_id_companies_id_fk",
          "tableFrom": "browser_use_sessions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "browser_use_sessions_issue_id_issues_id_fk": {
          "name": "browser_use_sessions_issue_id_issues_id_fk",
          "tableFrom": "browser_use_sessions",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "browser_use_sessions_agent_id_agents_id_fk": {
          "name": "browser_use_sessions_agent_id_agents_id_fk",
          "tableFrom": "browser_use_sessions",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "browser_use_sessions_connection_id_tool_connections_id_fk": {
          "name": "browser_use_sessions_connection_id_tool_connections_id_fk",
          "tableFrom": "browser_use_sessions",
          "tableTo": "tool_connections",
          "columnsFrom": [
            "connection_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "browser_use_sessions_grant_id_connection_grants_id_fk": {
          "name": "browser_use_sessions_grant_id_connection_grants_id_fk",
          "tableFrom": "browser_use_sessions",
          "tableTo": "connection_grants",
          "columnsFrom": [
            "grant_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.browser_use_settings": {
      "name": "browser_use_settings",
      "schema": "",
      "columns": {
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "allowed_profile_ids": {
          "name": "allowed_profile_ids",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "max_cost_usd": {
          "name": "max_cost_usd",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {},
      "foreignKeys": {
        "browser_use_settings_grant_id_connection_grants_id_fk": {
          "name": "browser_use_settings_grant_id_connection_grants_id_fk",
          "tableFrom": "browser_use_settings",
          "tableTo": "connection_grants",
          "columnsFrom": [
            "grant_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "browser_use_settings_company_id_companies_id_fk": {
          "name": "browser_use_settings_company_id_companies_id_fk",
          "tableFrom": "browser_use_settings",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.budget_incidents": {
      "name": "budget_incidents",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "policy_id": {
          "name": "policy_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "scope_type": {
          "name": "scope_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "scope_id": {
          "name": "scope_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "metric": {
          "name": "metric",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "window_kind": {
          "name": "window_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "window_start": {
          "name": "window_start",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "window_end": {
          "name": "window_end",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "threshold_type": {
          "name": "threshold_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "amount_limit": {
          "name": "amount_limit",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "amount_observed": {
          "name": "amount_observed",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'open'"
        },
        "approval_id": {
          "name": "approval_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "resolved_at": {
          "name": "resolved_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "budget_incidents_company_status_idx": {
          "name": "budget_incidents_company_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "budget_incidents_company_scope_idx": {
          "name": "budget_incidents_company_scope_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "scope_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "scope_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "budget_incidents_policy_window_threshold_idx": {
          "name": "budget_incidents_policy_window_threshold_idx",
          "columns": [
            {
              "expression": "policy_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "window_start",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "threshold_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"budget_incidents\".\"status\" = 'open'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "budget_incidents_company_id_companies_id_fk": {
          "name": "budget_incidents_company_id_companies_id_fk",
          "tableFrom": "budget_incidents",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "budget_incidents_policy_id_budget_policies_id_fk": {
          "name": "budget_incidents_policy_id_budget_policies_id_fk",
          "tableFrom": "budget_incidents",
          "tableTo": "budget_policies",
          "columnsFrom": [
            "policy_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "budget_incidents_approval_id_approvals_id_fk": {
          "name": "budget_incidents_approval_id_approvals_id_fk",
          "tableFrom": "budget_incidents",
          "tableTo": "approvals",
          "columnsFrom": [
            "approval_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.budget_policies": {
      "name": "budget_policies",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "scope_type": {
          "name": "scope_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "scope_id": {
          "name": "scope_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "metric": {
          "name": "metric",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'billed_cents'"
        },
        "window_kind": {
          "name": "window_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "amount": {
          "name": "amount",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "reservation_cents": {
          "name": "reservation_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true,
          "default": "'0'"
        },
        "warn_percent": {
          "name": "warn_percent",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 80
        },
        "hard_stop_enabled": {
          "name": "hard_stop_enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "unpriced_usage_policy": {
          "name": "unpriced_usage_policy",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'block'"
        },
        "notify_enabled": {
          "name": "notify_enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "is_active": {
          "name": "is_active",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "enforcement_version": {
          "name": "enforcement_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "enforcement_delivered_version": {
          "name": "enforcement_delivered_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "updated_by_user_id": {
          "name": "updated_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "budget_policies_company_scope_active_idx": {
          "name": "budget_policies_company_scope_active_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "scope_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "scope_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "is_active",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "budget_policies_company_window_idx": {
          "name": "budget_policies_company_window_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "window_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "metric",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "budget_policies_company_scope_metric_unique_idx": {
          "name": "budget_policies_company_scope_metric_unique_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "scope_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "scope_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "metric",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "window_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "budget_policies_company_id_companies_id_fk": {
          "name": "budget_policies_company_id_companies_id_fk",
          "tableFrom": "budget_policies",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "budget_policies_reservation_nonnegative": {
          "name": "budget_policies_reservation_nonnegative",
          "value": "\"budget_policies\".\"reservation_cents\" >= 0"
        }
      },
      "isRLSEnabled": false
    },
    "public.built_in_managed_resources": {
      "name": "built_in_managed_resources",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "bundle_key": {
          "name": "bundle_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "resource_kind": {
          "name": "resource_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "resource_key": {
          "name": "resource_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "resource_id": {
          "name": "resource_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "stock_version": {
          "name": "stock_version",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "stock_hash": {
          "name": "stock_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "defaults_json": {
          "name": "defaults_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "built_in_managed_resources_company_idx": {
          "name": "built_in_managed_resources_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "built_in_managed_resources_resource_idx": {
          "name": "built_in_managed_resources_resource_idx",
          "columns": [
            {
              "expression": "resource_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "resource_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "built_in_managed_resources_company_bundle_resource_uq": {
          "name": "built_in_managed_resources_company_bundle_resource_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "bundle_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "resource_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "resource_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "built_in_managed_resources_company_id_companies_id_fk": {
          "name": "built_in_managed_resources_company_id_companies_id_fk",
          "tableFrom": "built_in_managed_resources",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.case_access_sources": {
      "name": "case_access_sources",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "case_id": {
          "name": "case_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_kind": {
          "name": "source_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_id": {
          "name": "source_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "case_access_sources_case_source_uq": {
          "name": "case_access_sources_case_source_uq",
          "columns": [
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_access_sources_company_case_idx": {
          "name": "case_access_sources_company_case_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "case_access_sources_company_id_companies_id_fk": {
          "name": "case_access_sources_company_id_companies_id_fk",
          "tableFrom": "case_access_sources",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_access_sources_case_id_cases_id_fk": {
          "name": "case_access_sources_case_id_cases_id_fk",
          "tableFrom": "case_access_sources",
          "tableTo": "cases",
          "columnsFrom": [
            "case_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "case_access_sources_kind_check": {
          "name": "case_access_sources_kind_check",
          "value": "\"case_access_sources\".\"source_kind\" in ('issue', 'project')"
        }
      },
      "isRLSEnabled": false
    },
    "public.case_attachments": {
      "name": "case_attachments",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "case_id": {
          "name": "case_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "asset_id": {
          "name": "asset_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "case_attachments_company_case_idx": {
          "name": "case_attachments_company_case_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_attachments_asset_uq": {
          "name": "case_attachments_asset_uq",
          "columns": [
            {
              "expression": "asset_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "case_attachments_company_id_companies_id_fk": {
          "name": "case_attachments_company_id_companies_id_fk",
          "tableFrom": "case_attachments",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_attachments_case_id_cases_id_fk": {
          "name": "case_attachments_case_id_cases_id_fk",
          "tableFrom": "case_attachments",
          "tableTo": "cases",
          "columnsFrom": [
            "case_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_attachments_asset_id_assets_id_fk": {
          "name": "case_attachments_asset_id_assets_id_fk",
          "tableFrom": "case_attachments",
          "tableTo": "assets",
          "columnsFrom": [
            "asset_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.case_documents": {
      "name": "case_documents",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "case_id": {
          "name": "case_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "document_id": {
          "name": "document_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "case_documents_company_case_key_uq": {
          "name": "case_documents_company_case_key_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_documents_document_uq": {
          "name": "case_documents_document_uq",
          "columns": [
            {
              "expression": "document_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_documents_company_case_updated_idx": {
          "name": "case_documents_company_case_updated_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "updated_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "case_documents_company_id_companies_id_fk": {
          "name": "case_documents_company_id_companies_id_fk",
          "tableFrom": "case_documents",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_documents_case_id_cases_id_fk": {
          "name": "case_documents_case_id_cases_id_fk",
          "tableFrom": "case_documents",
          "tableTo": "cases",
          "columnsFrom": [
            "case_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_documents_document_id_documents_id_fk": {
          "name": "case_documents_document_id_documents_id_fk",
          "tableFrom": "case_documents",
          "tableTo": "documents",
          "columnsFrom": [
            "document_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.case_events": {
      "name": "case_events",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "case_id": {
          "name": "case_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "actor_type": {
          "name": "actor_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "actor_user_id": {
          "name": "actor_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "actor_agent_id": {
          "name": "actor_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "payload": {
          "name": "payload",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "case_events_case_created_idx": {
          "name": "case_events_case_created_idx",
          "columns": [
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_events_company_case_idx": {
          "name": "case_events_company_case_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "case_events_company_id_companies_id_fk": {
          "name": "case_events_company_id_companies_id_fk",
          "tableFrom": "case_events",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_events_case_id_cases_id_fk": {
          "name": "case_events_case_id_cases_id_fk",
          "tableFrom": "case_events",
          "tableTo": "cases",
          "columnsFrom": [
            "case_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_events_actor_agent_id_agents_id_fk": {
          "name": "case_events_actor_agent_id_agents_id_fk",
          "tableFrom": "case_events",
          "tableTo": "agents",
          "columnsFrom": [
            "actor_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "case_events_kind_check": {
          "name": "case_events_kind_check",
          "value": "\"case_events\".\"kind\" in (\n        'created',\n        'updated',\n        'fields_changed',\n        'status_changed',\n        'issue_linked',\n        'issue_unlinked',\n        'document_revised',\n        'child_linked',\n        'attachment_added',\n        'label_added',\n        'label_removed',\n        'handoff_requested',\n        'handoff_applied',\n        'handoff_delivered',\n        'handoff_completed',\n        'handoff_cancelled'\n      )"
        },
        "case_events_actor_type_check": {
          "name": "case_events_actor_type_check",
          "value": "\"case_events\".\"actor_type\" in ('user', 'agent', 'system')"
        }
      },
      "isRLSEnabled": false
    },
    "public.case_handoffs": {
      "name": "case_handoffs",
      "schema": "",
      "columns": {
        "workflow_transition": {
          "name": "workflow_transition",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "workflow_prompt": {
          "name": "workflow_prompt",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "base_workflow_document_revision_id": {
          "name": "base_workflow_document_revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "case_id": {
          "name": "case_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "version": {
          "name": "version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "from_agent_id": {
          "name": "from_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "destination_kind": {
          "name": "destination_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'agent'"
        },
        "to_agent_id": {
          "name": "to_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "phase": {
          "name": "phase",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "instructions": {
          "name": "instructions",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "comment_id": {
          "name": "comment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "actor_type": {
          "name": "actor_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "actor_id": {
          "name": "actor_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "actor_context": {
          "name": "actor_context",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "source_run_id": {
          "name": "source_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "expected_issue_status_version": {
          "name": "expected_issue_status_version",
          "type": "bigint",
          "primaryKey": false,
          "notNull": false
        },
        "applied_issue_status_version": {
          "name": "applied_issue_status_version",
          "type": "bigint",
          "primaryKey": false,
          "notNull": false
        },
        "wakeup_request_id": {
          "name": "wakeup_request_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "input_fingerprint": {
          "name": "input_fingerprint",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "attempt_count": {
          "name": "attempt_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "next_attempt_at": {
          "name": "next_attempt_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "lease_expires_at": {
          "name": "lease_expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_error_code": {
          "name": "last_error_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "last_error": {
          "name": "last_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "assignment_applied_at": {
          "name": "assignment_applied_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "delivered_at": {
          "name": "delivered_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "completed_at": {
          "name": "completed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "cancelled_at": {
          "name": "cancelled_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "case_handoffs_case_version_uq": {
          "name": "case_handoffs_case_version_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "version",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_handoffs_actor_idempotency_uq": {
          "name": "case_handoffs_actor_idempotency_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "actor_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "actor_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_handoffs_pending_case_uq": {
          "name": "case_handoffs_pending_case_uq",
          "columns": [
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"case_handoffs\".\"state\" in ('awaiting_release', 'pending_dispatch', 'awaiting_completion')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_handoffs_pending_issue_uq": {
          "name": "case_handoffs_pending_issue_uq",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"case_handoffs\".\"state\" in ('awaiting_release', 'pending_dispatch', 'awaiting_completion')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_handoffs_pending_attempt_idx": {
          "name": "case_handoffs_pending_attempt_idx",
          "columns": [
            {
              "expression": "next_attempt_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"case_handoffs\".\"state\" in ('awaiting_release', 'pending_dispatch')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_handoffs_case_created_idx": {
          "name": "case_handoffs_case_created_idx",
          "columns": [
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_handoffs_source_run_idx": {
          "name": "case_handoffs_source_run_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"case_handoffs\".\"source_run_id\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_handoffs_wakeup_request_uq": {
          "name": "case_handoffs_wakeup_request_uq",
          "columns": [
            {
              "expression": "wakeup_request_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "case_handoffs_company_id_companies_id_fk": {
          "name": "case_handoffs_company_id_companies_id_fk",
          "tableFrom": "case_handoffs",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_handoffs_case_id_cases_id_fk": {
          "name": "case_handoffs_case_id_cases_id_fk",
          "tableFrom": "case_handoffs",
          "tableTo": "cases",
          "columnsFrom": [
            "case_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_handoffs_issue_id_issues_id_fk": {
          "name": "case_handoffs_issue_id_issues_id_fk",
          "tableFrom": "case_handoffs",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "case_handoffs_from_agent_id_agents_id_fk": {
          "name": "case_handoffs_from_agent_id_agents_id_fk",
          "tableFrom": "case_handoffs",
          "tableTo": "agents",
          "columnsFrom": [
            "from_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "case_handoffs_to_agent_id_agents_id_fk": {
          "name": "case_handoffs_to_agent_id_agents_id_fk",
          "tableFrom": "case_handoffs",
          "tableTo": "agents",
          "columnsFrom": [
            "to_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "case_handoffs_state_check": {
          "name": "case_handoffs_state_check",
          "value": "\"case_handoffs\".\"state\" in ('awaiting_release', 'pending_dispatch', 'delivered', 'awaiting_completion', 'completed', 'cancelled')"
        },
        "case_handoffs_destination_check": {
          "name": "case_handoffs_destination_check",
          "value": "(\"case_handoffs\".\"destination_kind\" = 'agent' and \"case_handoffs\".\"to_agent_id\" is not null) or (\"case_handoffs\".\"destination_kind\" = 'done' and \"case_handoffs\".\"to_agent_id\" is null)"
        },
        "case_handoffs_destination_state_check": {
          "name": "case_handoffs_destination_state_check",
          "value": "(\"case_handoffs\".\"destination_kind\" = 'agent' and \"case_handoffs\".\"state\" in ('awaiting_release', 'pending_dispatch', 'delivered', 'cancelled')) or (\"case_handoffs\".\"destination_kind\" = 'done' and \"case_handoffs\".\"state\" in ('awaiting_completion', 'completed', 'cancelled'))"
        },
        "case_handoffs_actor_type_check": {
          "name": "case_handoffs_actor_type_check",
          "value": "\"case_handoffs\".\"actor_type\" in ('agent', 'user', 'system')"
        }
      },
      "isRLSEnabled": false
    },
    "public.case_issue_links": {
      "name": "case_issue_links",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "case_id": {
          "name": "case_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "role": {
          "name": "role",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_by_run_id": {
          "name": "created_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "case_issue_links_case_issue_uq": {
          "name": "case_issue_links_case_issue_uq",
          "columns": [
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_issue_links_company_case_idx": {
          "name": "case_issue_links_company_case_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_issue_links_issue_idx": {
          "name": "case_issue_links_issue_idx",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "case_issue_links_company_id_companies_id_fk": {
          "name": "case_issue_links_company_id_companies_id_fk",
          "tableFrom": "case_issue_links",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_issue_links_case_id_cases_id_fk": {
          "name": "case_issue_links_case_id_cases_id_fk",
          "tableFrom": "case_issue_links",
          "tableTo": "cases",
          "columnsFrom": [
            "case_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_issue_links_issue_id_issues_id_fk": {
          "name": "case_issue_links_issue_id_issues_id_fk",
          "tableFrom": "case_issue_links",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "case_issue_links_role_check": {
          "name": "case_issue_links_role_check",
          "value": "\"case_issue_links\".\"role\" in ('origin', 'work', 'reference')"
        }
      },
      "isRLSEnabled": false
    },
    "public.case_labels": {
      "name": "case_labels",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "case_id": {
          "name": "case_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "label_id": {
          "name": "label_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "case_labels_case_label_uq": {
          "name": "case_labels_case_label_uq",
          "columns": [
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "label_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_labels_company_case_idx": {
          "name": "case_labels_company_case_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "case_labels_label_idx": {
          "name": "case_labels_label_idx",
          "columns": [
            {
              "expression": "label_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "case_labels_company_id_companies_id_fk": {
          "name": "case_labels_company_id_companies_id_fk",
          "tableFrom": "case_labels",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_labels_case_id_cases_id_fk": {
          "name": "case_labels_case_id_cases_id_fk",
          "tableFrom": "case_labels",
          "tableTo": "cases",
          "columnsFrom": [
            "case_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "case_labels_label_id_labels_id_fk": {
          "name": "case_labels_label_id_labels_id_fk",
          "tableFrom": "case_labels",
          "tableTo": "labels",
          "columnsFrom": [
            "label_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.cases": {
      "name": "cases",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "project_id": {
          "name": "project_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "work_issue_id": {
          "name": "work_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "phase": {
          "name": "phase",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "workflow_id": {
          "name": "workflow_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "handoff_version": {
          "name": "handoff_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "case_number": {
          "name": "case_number",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "identifier": {
          "name": "identifier",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "case_type": {
          "name": "case_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "summary": {
          "name": "summary",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'draft'"
        },
        "fields": {
          "name": "fields",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "parent_case_id": {
          "name": "parent_case_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "completed_at": {
          "name": "completed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "cases_company_case_number_uq": {
          "name": "cases_company_case_number_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_number",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cases_identifier_uq": {
          "name": "cases_identifier_uq",
          "columns": [
            {
              "expression": "identifier",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cases_work_issue_uq": {
          "name": "cases_work_issue_uq",
          "columns": [
            {
              "expression": "work_issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"cases\".\"work_issue_id\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cases_company_type_key_uq": {
          "name": "cases_company_type_key_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cases_company_status_idx": {
          "name": "cases_company_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cases_company_type_idx": {
          "name": "cases_company_type_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cases_company_project_idx": {
          "name": "cases_company_project_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "project_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cases_parent_idx": {
          "name": "cases_parent_idx",
          "columns": [
            {
              "expression": "parent_case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cases_title_search_idx": {
          "name": "cases_title_search_idx",
          "columns": [
            {
              "expression": "title",
              "isExpression": false,
              "asc": true,
              "nulls": "last",
              "opclass": "gin_trgm_ops"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "gin",
          "with": {}
        },
        "cases_identifier_search_idx": {
          "name": "cases_identifier_search_idx",
          "columns": [
            {
              "expression": "identifier",
              "isExpression": false,
              "asc": true,
              "nulls": "last",
              "opclass": "gin_trgm_ops"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "gin",
          "with": {}
        },
        "cases_summary_search_idx": {
          "name": "cases_summary_search_idx",
          "columns": [
            {
              "expression": "summary",
              "isExpression": false,
              "asc": true,
              "nulls": "last",
              "opclass": "gin_trgm_ops"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "gin",
          "with": {}
        }
      },
      "foreignKeys": {
        "cases_company_id_companies_id_fk": {
          "name": "cases_company_id_companies_id_fk",
          "tableFrom": "cases",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "cases_project_id_projects_id_fk": {
          "name": "cases_project_id_projects_id_fk",
          "tableFrom": "cases",
          "tableTo": "projects",
          "columnsFrom": [
            "project_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "cases_work_issue_id_issues_id_fk": {
          "name": "cases_work_issue_id_issues_id_fk",
          "tableFrom": "cases",
          "tableTo": "issues",
          "columnsFrom": [
            "work_issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "cases_workflow_id_workflows_id_fk": {
          "name": "cases_workflow_id_workflows_id_fk",
          "tableFrom": "cases",
          "tableTo": "workflows",
          "columnsFrom": [
            "workflow_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "cases_parent_case_id_cases_id_fk": {
          "name": "cases_parent_case_id_cases_id_fk",
          "tableFrom": "cases",
          "tableTo": "cases",
          "columnsFrom": [
            "parent_case_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "cases_created_by_agent_id_agents_id_fk": {
          "name": "cases_created_by_agent_id_agents_id_fk",
          "tableFrom": "cases",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "cases_status_check": {
          "name": "cases_status_check",
          "value": "\"cases\".\"status\" in ('draft', 'in_progress', 'in_review', 'approved', 'done', 'cancelled')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_actions": {
      "name": "chat_actions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "delivery_id": {
          "name": "delivery_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "principal_id": {
          "name": "principal_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider_action_id": {
          "name": "provider_action_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "payload": {
          "name": "payload",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'received'"
        },
        "result": {
          "name": "result",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_actions_provider_action_uq": {
          "name": "chat_actions_provider_action_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_action_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_actions_company_id_companies_id_fk": {
          "name": "chat_actions_company_id_companies_id_fk",
          "tableFrom": "chat_actions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_actions_delivery_id_chat_deliveries_id_fk": {
          "name": "chat_actions_delivery_id_chat_deliveries_id_fk",
          "tableFrom": "chat_actions",
          "tableTo": "chat_deliveries",
          "columnsFrom": [
            "delivery_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "chat_actions_company_delivery_fk": {
          "name": "chat_actions_company_delivery_fk",
          "tableFrom": "chat_actions",
          "tableTo": "chat_deliveries",
          "columnsFrom": [
            "company_id",
            "delivery_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_actions_company_conversation_fk": {
          "name": "chat_actions_company_conversation_fk",
          "tableFrom": "chat_actions",
          "tableTo": "chat_conversations",
          "columnsFrom": [
            "company_id",
            "conversation_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_actions_company_principal_fk": {
          "name": "chat_actions_company_principal_fk",
          "tableFrom": "chat_actions",
          "tableTo": "chat_external_principals",
          "columnsFrom": [
            "company_id",
            "principal_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_actions_company_endpoint_fk": {
          "name": "chat_actions_company_endpoint_fk",
          "tableFrom": "chat_actions",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.chat_agent_routes": {
      "name": "chat_agent_routes",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_endpoint_id": {
          "name": "source_endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "destination_endpoint_id": {
          "name": "destination_endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "enabled": {
          "name": "enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "trigger_mode": {
          "name": "trigger_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'explicit_mention'"
        },
        "max_hops": {
          "name": "max_hops",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_agent_routes_pair_uq": {
          "name": "chat_agent_routes_pair_uq",
          "columns": [
            {
              "expression": "source_endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "destination_endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_agent_routes_company_id_companies_id_fk": {
          "name": "chat_agent_routes_company_id_companies_id_fk",
          "tableFrom": "chat_agent_routes",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_agent_routes_company_source_fk": {
          "name": "chat_agent_routes_company_source_fk",
          "tableFrom": "chat_agent_routes",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "source_endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_agent_routes_company_destination_fk": {
          "name": "chat_agent_routes_company_destination_fk",
          "tableFrom": "chat_agent_routes",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "destination_endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_agent_routes_hops_check": {
          "name": "chat_agent_routes_hops_check",
          "value": "\"chat_agent_routes\".\"max_hops\" between 1 and 8"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_conversations": {
      "name": "chat_conversations",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "resource_id": {
          "name": "resource_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "external_conversation_id": {
          "name": "external_conversation_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "external_thread_id": {
          "name": "external_thread_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "''"
        },
        "session_generation": {
          "name": "session_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "external_label": {
          "name": "external_label",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider_url": {
          "name": "provider_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "is_direct_message": {
          "name": "is_direct_message",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "communication_guidance": {
          "name": "communication_guidance",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "last_activity_at": {
          "name": "last_activity_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_conversations_issue_idx": {
          "name": "chat_conversations_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_conversations_thread_uq": {
          "name": "chat_conversations_thread_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "external_conversation_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "external_thread_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "session_generation",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_conversations_company_id_companies_id_fk": {
          "name": "chat_conversations_company_id_companies_id_fk",
          "tableFrom": "chat_conversations",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_conversations_resource_id_chat_endpoint_resources_id_fk": {
          "name": "chat_conversations_resource_id_chat_endpoint_resources_id_fk",
          "tableFrom": "chat_conversations",
          "tableTo": "chat_endpoint_resources",
          "columnsFrom": [
            "resource_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "chat_conversations_issue_id_issues_id_fk": {
          "name": "chat_conversations_issue_id_issues_id_fk",
          "tableFrom": "chat_conversations",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "chat_conversations_company_issue_fk": {
          "name": "chat_conversations_company_issue_fk",
          "tableFrom": "chat_conversations",
          "tableTo": "issues",
          "columnsFrom": [
            "company_id",
            "issue_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_conversations_company_endpoint_fk": {
          "name": "chat_conversations_company_endpoint_fk",
          "tableFrom": "chat_conversations",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_conversations_company_resource_fk": {
          "name": "chat_conversations_company_resource_fk",
          "tableFrom": "chat_conversations",
          "tableTo": "chat_endpoint_resources",
          "columnsFrom": [
            "company_id",
            "resource_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "chat_conversations_company_id_uq": {
          "name": "chat_conversations_company_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "chat_conversations_state_check": {
          "name": "chat_conversations_state_check",
          "value": "\"chat_conversations\".\"state\" in ('active', 'waiting', 'completed', 'unavailable', 'endpoint_removed')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_deliveries": {
      "name": "chat_deliveries",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "principal_id": {
          "name": "principal_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "provider_event_id": {
          "name": "provider_event_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "deduplication_key": {
          "name": "deduplication_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "event_kind": {
          "name": "event_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "normalized_event": {
          "name": "normalized_event",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'received'"
        },
        "attempts": {
          "name": "attempts",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "redacted_error": {
          "name": "redacted_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "next_attempt_at": {
          "name": "next_attempt_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "received_at": {
          "name": "received_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "processed_at": {
          "name": "processed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_deliveries_work_idx": {
          "name": "chat_deliveries_work_idx",
          "columns": [
            {
              "expression": "state",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "next_attempt_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_deliveries_event_uq": {
          "name": "chat_deliveries_event_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_event_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_deliveries_dedupe_uq": {
          "name": "chat_deliveries_dedupe_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "deduplication_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_deliveries_company_id_companies_id_fk": {
          "name": "chat_deliveries_company_id_companies_id_fk",
          "tableFrom": "chat_deliveries",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_deliveries_conversation_id_chat_conversations_id_fk": {
          "name": "chat_deliveries_conversation_id_chat_conversations_id_fk",
          "tableFrom": "chat_deliveries",
          "tableTo": "chat_conversations",
          "columnsFrom": [
            "conversation_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "chat_deliveries_principal_id_chat_external_principals_id_fk": {
          "name": "chat_deliveries_principal_id_chat_external_principals_id_fk",
          "tableFrom": "chat_deliveries",
          "tableTo": "chat_external_principals",
          "columnsFrom": [
            "principal_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "chat_deliveries_company_endpoint_fk": {
          "name": "chat_deliveries_company_endpoint_fk",
          "tableFrom": "chat_deliveries",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_deliveries_company_conversation_fk": {
          "name": "chat_deliveries_company_conversation_fk",
          "tableFrom": "chat_deliveries",
          "tableTo": "chat_conversations",
          "columnsFrom": [
            "company_id",
            "conversation_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_deliveries_company_principal_fk": {
          "name": "chat_deliveries_company_principal_fk",
          "tableFrom": "chat_deliveries",
          "tableTo": "chat_external_principals",
          "columnsFrom": [
            "company_id",
            "principal_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "chat_deliveries_company_id_uq": {
          "name": "chat_deliveries_company_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "chat_deliveries_state_check": {
          "name": "chat_deliveries_state_check",
          "value": "\"chat_deliveries\".\"state\" in ('received', 'filtered', 'processing', 'processed', 'retry', 'failed')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_endpoint_leases": {
      "name": "chat_endpoint_leases",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "lease_key": {
          "name": "lease_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "token": {
          "name": "token",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_endpoint_leases_active_uq": {
          "name": "chat_endpoint_leases_active_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "lease_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoint_leases_expiry_idx": {
          "name": "chat_endpoint_leases_expiry_idx",
          "columns": [
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_endpoint_leases_company_id_companies_id_fk": {
          "name": "chat_endpoint_leases_company_id_companies_id_fk",
          "tableFrom": "chat_endpoint_leases",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_endpoint_leases_company_endpoint_fk": {
          "name": "chat_endpoint_leases_company_endpoint_fk",
          "tableFrom": "chat_endpoint_leases",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.chat_endpoint_resources": {
      "name": "chat_endpoint_resources",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "type": {
          "name": "type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider_resource_id": {
          "name": "provider_resource_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "parent_provider_resource_id": {
          "name": "parent_provider_resource_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "label": {
          "name": "label",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "detail": {
          "name": "detail",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "provider_url": {
          "name": "provider_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "availability": {
          "name": "availability",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'available'"
        },
        "enabled": {
          "name": "enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "execution_defaults": {
          "name": "execution_defaults",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_endpoint_resources_endpoint_idx": {
          "name": "chat_endpoint_resources_endpoint_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoint_resources_external_uq": {
          "name": "chat_endpoint_resources_external_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_resource_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_endpoint_resources_company_id_companies_id_fk": {
          "name": "chat_endpoint_resources_company_id_companies_id_fk",
          "tableFrom": "chat_endpoint_resources",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_endpoint_resources_company_endpoint_fk": {
          "name": "chat_endpoint_resources_company_endpoint_fk",
          "tableFrom": "chat_endpoint_resources",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "chat_endpoint_resources_company_id_uq": {
          "name": "chat_endpoint_resources_company_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "chat_endpoint_resources_availability_check": {
          "name": "chat_endpoint_resources_availability_check",
          "value": "\"chat_endpoint_resources\".\"availability\" in ('available', 'unavailable', 'removed')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_endpoints": {
      "name": "chat_endpoints",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "public_id": {
          "name": "public_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "publication_mode": {
          "name": "publication_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'automatic'"
        },
        "external_execution_policy": {
          "name": "external_execution_policy",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'restricted'"
        },
        "assigned_agent_id": {
          "name": "assigned_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "sponsor_user_id": {
          "name": "sponsor_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'draft'"
        },
        "deployment_mode": {
          "name": "deployment_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'direct'"
        },
        "provider_account_id": {
          "name": "provider_account_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "provider_account_label": {
          "name": "provider_account_label",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "bot_external_id": {
          "name": "bot_external_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "bot_username": {
          "name": "bot_username",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "bot_display_name": {
          "name": "bot_display_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "bot_avatar_url": {
          "name": "bot_avatar_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "communication_instructions": {
          "name": "communication_instructions",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "''"
        },
        "execution_defaults": {
          "name": "execution_defaults",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "allow_direct_messages": {
          "name": "allow_direct_messages",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "require_at_mention": {
          "name": "require_at_mention",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "allow_group_chats": {
          "name": "allow_group_chats",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "allow_unlinked_people": {
          "name": "allow_unlinked_people",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "concurrency_policy": {
          "name": "concurrency_policy",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'queue'"
        },
        "capabilities": {
          "name": "capabilities",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{\"threads\":false,\"directMessages\":false,\"nativeStreaming\":false,\"messageEdits\":false,\"messageDeletes\":false,\"reactions\":false,\"files\":false,\"cards\":false,\"actions\":false,\"modals\":false,\"slashCommands\":false,\"ephemeralMessages\":false,\"proactiveDirectMessages\":false}'::jsonb"
        },
        "setup": {
          "name": "setup",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{\"step\":\"provider_setup\"}'::jsonb"
        },
        "health_message": {
          "name": "health_message",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "last_event_at": {
          "name": "last_event_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_publication_at": {
          "name": "last_publication_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_error": {
          "name": "last_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "activated_at": {
          "name": "activated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "archived_at": {
          "name": "archived_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_endpoints_company_idx": {
          "name": "chat_endpoints_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoints_agent_idx": {
          "name": "chat_endpoints_agent_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "assigned_agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoints_status_idx": {
          "name": "chat_endpoints_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoints_public_id_uq": {
          "name": "chat_endpoints_public_id_uq",
          "columns": [
            {
              "expression": "public_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoints_agentmail_inbox_uq": {
          "name": "chat_endpoints_agentmail_inbox_uq",
          "columns": [
            {
              "expression": "bot_external_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"chat_endpoints\".\"provider\" = 'agentmail' and \"chat_endpoints\".\"status\" != 'archived' and \"chat_endpoints\".\"bot_external_id\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoints_connection_uq": {
          "name": "chat_endpoints_connection_uq",
          "columns": [
            {
              "expression": "connection_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoints_live_bot_external_uq": {
          "name": "chat_endpoints_live_bot_external_uq",
          "columns": [
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_account_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "bot_external_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n          and \"chat_endpoints\".\"provider_account_id\" is not null\n          and \"chat_endpoints\".\"bot_external_id\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoints_photon_number_uq": {
          "name": "chat_endpoints_photon_number_uq",
          "columns": [
            {
              "expression": "bot_external_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"chat_endpoints\".\"provider\" = 'imessage-photon' and \"chat_endpoints\".\"status\" <> 'archived' and \"chat_endpoints\".\"bot_external_id\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoints_live_discord_bot_external_uq": {
          "name": "chat_endpoints_live_discord_bot_external_uq",
          "columns": [
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "bot_external_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"chat_endpoints\".\"provider\" = 'discord'\n          and \"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n          and \"chat_endpoints\".\"bot_external_id\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoints_live_global_app_bot_external_uq": {
          "name": "chat_endpoints_live_global_app_bot_external_uq",
          "columns": [
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "bot_external_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"chat_endpoints\".\"provider\" in ('github', 'microsoft-teams')\n          and \"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n          and \"chat_endpoints\".\"bot_external_id\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_endpoints_live_bot_username_uq": {
          "name": "chat_endpoints_live_bot_username_uq",
          "columns": [
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_account_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "bot_username",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n          and \"chat_endpoints\".\"provider_account_id\" is not null\n          and \"chat_endpoints\".\"bot_username\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_endpoints_company_id_companies_id_fk": {
          "name": "chat_endpoints_company_id_companies_id_fk",
          "tableFrom": "chat_endpoints",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_endpoints_assigned_agent_id_agents_id_fk": {
          "name": "chat_endpoints_assigned_agent_id_agents_id_fk",
          "tableFrom": "chat_endpoints",
          "tableTo": "agents",
          "columnsFrom": [
            "assigned_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "chat_endpoints_company_agent_fk": {
          "name": "chat_endpoints_company_agent_fk",
          "tableFrom": "chat_endpoints",
          "tableTo": "agents",
          "columnsFrom": [
            "company_id",
            "assigned_agent_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_endpoints_company_connection_fk": {
          "name": "chat_endpoints_company_connection_fk",
          "tableFrom": "chat_endpoints",
          "tableTo": "tool_connections",
          "columnsFrom": [
            "company_id",
            "connection_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "chat_endpoints_company_id_uq": {
          "name": "chat_endpoints_company_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "chat_endpoints_publication_mode_check": {
          "name": "chat_endpoints_publication_mode_check",
          "value": "\"chat_endpoints\".\"publication_mode\" in ('automatic', 'explicit')"
        },
        "chat_endpoints_execution_policy_check": {
          "name": "chat_endpoints_execution_policy_check",
          "value": "\"chat_endpoints\".\"external_execution_policy\" in ('restricted', 'agent')"
        },
        "chat_endpoints_email_policy_check": {
          "name": "chat_endpoints_email_policy_check",
          "value": "\"chat_endpoints\".\"provider\" <> 'agentmail' or (\"chat_endpoints\".\"publication_mode\" = 'explicit' and \"chat_endpoints\".\"external_execution_policy\" = 'agent')"
        },
        "chat_endpoints_provider_check": {
          "name": "chat_endpoints_provider_check",
          "value": "\"chat_endpoints\".\"provider\" in ('slack', 'github', 'discord', 'microsoft-teams', 'telegram', 'speko', 'agentmail', 'imessage-photon')"
        },
        "chat_endpoints_status_check": {
          "name": "chat_endpoints_status_check",
          "value": "\"chat_endpoints\".\"status\" in ('draft', 'verifying', 'active', 'paused', 'attention', 'revoked', 'archived')"
        },
        "chat_endpoints_deployment_check": {
          "name": "chat_endpoints_deployment_check",
          "value": "\"chat_endpoints\".\"deployment_mode\" in ('direct', 'relay')"
        },
        "chat_endpoints_concurrency_check": {
          "name": "chat_endpoints_concurrency_check",
          "value": "\"chat_endpoints\".\"concurrency_policy\" in ('burst', 'queue', 'debounce', 'drop', 'concurrent')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_external_principals": {
      "name": "chat_external_principals",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider_account_id": {
          "name": "provider_account_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "external_id": {
          "name": "external_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'user'"
        },
        "display_name": {
          "name": "display_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "handle": {
          "name": "handle",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "avatar_url": {
          "name": "avatar_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "is_bot": {
          "name": "is_bot",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "last_seen_at": {
          "name": "last_seen_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_external_principals_company_idx": {
          "name": "chat_external_principals_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_external_principals_external_uq": {
          "name": "chat_external_principals_external_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_account_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "external_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_external_principals_company_id_companies_id_fk": {
          "name": "chat_external_principals_company_id_companies_id_fk",
          "tableFrom": "chat_external_principals",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "chat_external_principals_company_id_uq": {
          "name": "chat_external_principals_company_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "chat_external_principals_provider_check": {
          "name": "chat_external_principals_provider_check",
          "value": "\"chat_external_principals\".\"provider\" in ('slack', 'github', 'discord', 'microsoft-teams', 'telegram', 'speko', 'agentmail', 'imessage-photon')"
        },
        "chat_external_principals_kind_check": {
          "name": "chat_external_principals_kind_check",
          "value": "\"chat_external_principals\".\"kind\" in ('user', 'bot', 'app', 'system')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_identity_links": {
      "name": "chat_identity_links",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "principal_id": {
          "name": "principal_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "paperclip_user_id": {
          "name": "paperclip_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "confirmation_token_hash": {
          "name": "confirmation_token_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "confirmed_at": {
          "name": "confirmed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "revoked_at": {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_identity_links_user_idx": {
          "name": "chat_identity_links_user_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "paperclip_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_identity_links_endpoint_principal_uq": {
          "name": "chat_identity_links_endpoint_principal_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "principal_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_identity_links_company_id_companies_id_fk": {
          "name": "chat_identity_links_company_id_companies_id_fk",
          "tableFrom": "chat_identity_links",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_identity_links_company_endpoint_fk": {
          "name": "chat_identity_links_company_endpoint_fk",
          "tableFrom": "chat_identity_links",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_identity_links_company_principal_fk": {
          "name": "chat_identity_links_company_principal_fk",
          "tableFrom": "chat_identity_links",
          "tableTo": "chat_external_principals",
          "columnsFrom": [
            "company_id",
            "principal_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_identity_links_status_check": {
          "name": "chat_identity_links_status_check",
          "value": "\"chat_identity_links\".\"status\" in ('pending', 'linked', 'revoked', 'expired')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_message_links": {
      "name": "chat_message_links",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "delivery_id": {
          "name": "delivery_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "publication_id": {
          "name": "publication_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "comment_id": {
          "name": "comment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "provider_message_id": {
          "name": "provider_message_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "direction": {
          "name": "direction",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_message_links_provider_message_uq": {
          "name": "chat_message_links_provider_message_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "conversation_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_message_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_message_links_company_id_companies_id_fk": {
          "name": "chat_message_links_company_id_companies_id_fk",
          "tableFrom": "chat_message_links",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_message_links_delivery_id_chat_deliveries_id_fk": {
          "name": "chat_message_links_delivery_id_chat_deliveries_id_fk",
          "tableFrom": "chat_message_links",
          "tableTo": "chat_deliveries",
          "columnsFrom": [
            "delivery_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "chat_message_links_publication_id_chat_publications_id_fk": {
          "name": "chat_message_links_publication_id_chat_publications_id_fk",
          "tableFrom": "chat_message_links",
          "tableTo": "chat_publications",
          "columnsFrom": [
            "publication_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "chat_message_links_comment_id_issue_comments_id_fk": {
          "name": "chat_message_links_comment_id_issue_comments_id_fk",
          "tableFrom": "chat_message_links",
          "tableTo": "issue_comments",
          "columnsFrom": [
            "comment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "chat_message_links_company_endpoint_fk": {
          "name": "chat_message_links_company_endpoint_fk",
          "tableFrom": "chat_message_links",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_message_links_company_delivery_fk": {
          "name": "chat_message_links_company_delivery_fk",
          "tableFrom": "chat_message_links",
          "tableTo": "chat_deliveries",
          "columnsFrom": [
            "company_id",
            "delivery_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_message_links_company_publication_fk": {
          "name": "chat_message_links_company_publication_fk",
          "tableFrom": "chat_message_links",
          "tableTo": "chat_publications",
          "columnsFrom": [
            "company_id",
            "publication_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_message_links_company_comment_fk": {
          "name": "chat_message_links_company_comment_fk",
          "tableFrom": "chat_message_links",
          "tableTo": "issue_comments",
          "columnsFrom": [
            "company_id",
            "comment_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_message_links_company_conversation_fk": {
          "name": "chat_message_links_company_conversation_fk",
          "tableFrom": "chat_message_links",
          "tableTo": "chat_conversations",
          "columnsFrom": [
            "company_id",
            "conversation_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_message_links_direction_check": {
          "name": "chat_message_links_direction_check",
          "value": "\"chat_message_links\".\"direction\" in ('inbound', 'outbound')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_publications": {
      "name": "chat_publications",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "comment_id": {
          "name": "comment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "payload": {
          "name": "payload",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "provider_message_id": {
          "name": "provider_message_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "provider_url": {
          "name": "provider_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "attempts": {
          "name": "attempts",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "redacted_error": {
          "name": "redacted_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "next_attempt_at": {
          "name": "next_attempt_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "published_at": {
          "name": "published_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_publications_company_id_uq": {
          "name": "chat_publications_company_id_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_publications_work_idx": {
          "name": "chat_publications_work_idx",
          "columns": [
            {
              "expression": "state",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "next_attempt_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_publications_idempotency_uq": {
          "name": "chat_publications_idempotency_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_publications_company_id_companies_id_fk": {
          "name": "chat_publications_company_id_companies_id_fk",
          "tableFrom": "chat_publications",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_publications_issue_id_issues_id_fk": {
          "name": "chat_publications_issue_id_issues_id_fk",
          "tableFrom": "chat_publications",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "chat_publications_comment_id_issue_comments_id_fk": {
          "name": "chat_publications_comment_id_issue_comments_id_fk",
          "tableFrom": "chat_publications",
          "tableTo": "issue_comments",
          "columnsFrom": [
            "comment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "chat_publications_company_issue_fk": {
          "name": "chat_publications_company_issue_fk",
          "tableFrom": "chat_publications",
          "tableTo": "issues",
          "columnsFrom": [
            "company_id",
            "issue_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_publications_company_comment_fk": {
          "name": "chat_publications_company_comment_fk",
          "tableFrom": "chat_publications",
          "tableTo": "issue_comments",
          "columnsFrom": [
            "company_id",
            "comment_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_publications_company_endpoint_fk": {
          "name": "chat_publications_company_endpoint_fk",
          "tableFrom": "chat_publications",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_publications_company_conversation_fk": {
          "name": "chat_publications_company_conversation_fk",
          "tableFrom": "chat_publications",
          "tableTo": "chat_conversations",
          "columnsFrom": [
            "company_id",
            "conversation_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_publications_state_check": {
          "name": "chat_publications_state_check",
          "value": "\"chat_publications\".\"state\" in ('pending', 'streaming', 'published', 'retry', 'delivery_unknown', 'failed', 'cancelled', 'awaiting_consent')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_sdk_state": {
      "name": "chat_sdk_state",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "state_key": {
          "name": "state_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "version": {
          "name": "version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "value": {
          "name": "value",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_sdk_state_key_uq": {
          "name": "chat_sdk_state_key_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "state_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_sdk_state_expiry_idx": {
          "name": "chat_sdk_state_expiry_idx",
          "columns": [
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_sdk_state_company_id_companies_id_fk": {
          "name": "chat_sdk_state_company_id_companies_id_fk",
          "tableFrom": "chat_sdk_state",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_sdk_state_company_endpoint_fk": {
          "name": "chat_sdk_state_company_endpoint_fk",
          "tableFrom": "chat_sdk_state",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.chat_completion_deliveries": {
      "name": "chat_completion_deliveries",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "task_id": {
          "name": "task_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "status_version": {
          "name": "status_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "attempts": {
          "name": "attempts",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "next_attempt_at": {
          "name": "next_attempt_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "target_run_id": {
          "name": "target_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "response_comment_id": {
          "name": "response_comment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "error": {
          "name": "error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_completion_deliveries_transition_uq": {
          "name": "chat_completion_deliveries_transition_uq",
          "columns": [
            {
              "expression": "task_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status_version",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_completion_deliveries_pending_idx": {
          "name": "chat_completion_deliveries_pending_idx",
          "columns": [
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "next_attempt_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_completion_deliveries_company_id_companies_id_fk": {
          "name": "chat_completion_deliveries_company_id_companies_id_fk",
          "tableFrom": "chat_completion_deliveries",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_completion_deliveries_task_id_chat_task_handoffs_task_id_fk": {
          "name": "chat_completion_deliveries_task_id_chat_task_handoffs_task_id_fk",
          "tableFrom": "chat_completion_deliveries",
          "tableTo": "chat_task_handoffs",
          "columnsFrom": [
            "task_id"
          ],
          "columnsTo": [
            "task_id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_completion_deliveries_target_run_id_heartbeat_runs_id_fk": {
          "name": "chat_completion_deliveries_target_run_id_heartbeat_runs_id_fk",
          "tableFrom": "chat_completion_deliveries",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "target_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "chat_completion_deliveries_response_comment_id_issue_comments_id_fk": {
          "name": "chat_completion_deliveries_response_comment_id_issue_comments_id_fk",
          "tableFrom": "chat_completion_deliveries",
          "tableTo": "issue_comments",
          "columnsFrom": [
            "response_comment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.chat_task_handoffs": {
      "name": "chat_task_handoffs",
      "schema": "",
      "columns": {
        "task_id": {
          "name": "task_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "session_generation": {
          "name": "session_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_task_handoffs_source_idx": {
          "name": "chat_task_handoffs_source_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "conversation_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_task_handoffs_task_id_issues_id_fk": {
          "name": "chat_task_handoffs_task_id_issues_id_fk",
          "tableFrom": "chat_task_handoffs",
          "tableTo": "issues",
          "columnsFrom": [
            "task_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_task_handoffs_company_id_companies_id_fk": {
          "name": "chat_task_handoffs_company_id_companies_id_fk",
          "tableFrom": "chat_task_handoffs",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_task_handoffs_conversation_id_issues_id_fk": {
          "name": "chat_task_handoffs_conversation_id_issues_id_fk",
          "tableFrom": "chat_task_handoffs",
          "tableTo": "issues",
          "columnsFrom": [
            "conversation_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_task_handoffs_agent_id_agents_id_fk": {
          "name": "chat_task_handoffs_agent_id_agents_id_fk",
          "tableFrom": "chat_task_handoffs",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.chat_discord_command_owners": {
      "name": "chat_discord_command_owners",
      "schema": "",
      "columns": {
        "application_id": {
          "name": "application_id",
          "type": "text",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "action_id": {
          "name": "action_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_discord_command_owners_application_check": {
          "name": "chat_discord_command_owners_application_check",
          "value": "\"chat_discord_command_owners\".\"application_id\" ~ '^[1-9][0-9]{16,19}$'"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_github_configurations": {
      "name": "chat_github_configurations",
      "schema": "",
      "columns": {
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "revision": {
          "name": "revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "configuration": {
          "name": "configuration",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "updated_by_user_id": {
          "name": "updated_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "chat_github_configurations_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {
          "name": "chat_github_configurations_company_id_endpoint_id_chat_endpoints_company_id_id_fk",
          "tableFrom": "chat_github_configurations",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_github_config_revision_check": {
          "name": "chat_github_config_revision_check",
          "value": "\"chat_github_configurations\".\"revision\" > 0"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_github_registrations": {
      "name": "chat_github_registrations",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "state_hash": {
          "name": "state_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "trusted_origin": {
          "name": "trusted_origin",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "owner_type": {
          "name": "owner_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'personal'"
        },
        "owner_login": {
          "name": "owner_login",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "app_name": {
          "name": "app_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "handoff": {
          "name": "handoff",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "consumed_at": {
          "name": "consumed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_github_registration_state_uq": {
          "name": "chat_github_registration_state_uq",
          "columns": [
            {
              "expression": "state_hash",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_github_registration_endpoint_idx": {
          "name": "chat_github_registration_endpoint_idx",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_github_registrations_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {
          "name": "chat_github_registrations_company_id_endpoint_id_chat_endpoints_company_id_id_fk",
          "tableFrom": "chat_github_registrations",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_github_registration_status_check": {
          "name": "chat_github_registration_status_check",
          "value": "\"chat_github_registrations\".\"status\" in ('pending', 'exchanging', 'completed', 'failed')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_github_reviews": {
      "name": "chat_github_reviews",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "repository_id": {
          "name": "repository_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "repository": {
          "name": "repository",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "pull_number": {
          "name": "pull_number",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "head_sha": {
          "name": "head_sha",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "delivery_id": {
          "name": "delivery_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "configuration_revision": {
          "name": "configuration_revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "policy_snapshot": {
          "name": "policy_snapshot",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "event": {
          "name": "event",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'queued'"
        },
        "assessment": {
          "name": "assessment",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "conclusion": {
          "name": "conclusion",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "check_id": {
          "name": "check_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "check_url": {
          "name": "check_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "summary_id": {
          "name": "summary_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "summary_url": {
          "name": "summary_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "publication_receipts": {
          "name": "publication_receipts",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_github_reviews_delivery_uq": {
          "name": "chat_github_reviews_delivery_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "delivery_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_github_reviews_pull_idx": {
          "name": "chat_github_reviews_pull_idx",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "repository_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "pull_number",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_github_reviews_task_idx": {
          "name": "chat_github_reviews_task_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_github_reviews_run_id_heartbeat_runs_id_fk": {
          "name": "chat_github_reviews_run_id_heartbeat_runs_id_fk",
          "tableFrom": "chat_github_reviews",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "chat_github_reviews_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {
          "name": "chat_github_reviews_company_id_endpoint_id_chat_endpoints_company_id_id_fk",
          "tableFrom": "chat_github_reviews",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_github_reviews_company_id_issue_id_issues_company_id_id_fk": {
          "name": "chat_github_reviews_company_id_issue_id_issues_company_id_id_fk",
          "tableFrom": "chat_github_reviews",
          "tableTo": "issues",
          "columnsFrom": [
            "company_id",
            "issue_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "chat_github_reviews_company_id_uq": {
          "name": "chat_github_reviews_company_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "chat_github_review_pull_number_check": {
          "name": "chat_github_review_pull_number_check",
          "value": "\"chat_github_reviews\".\"pull_number\" > 0"
        },
        "chat_github_review_state_check": {
          "name": "chat_github_review_state_check",
          "value": "\"chat_github_reviews\".\"state\" in ('queued', 'running', 'completed', 'incomplete', 'error', 'superseded', 'manual_required')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_slack_manager_grants": {
      "name": "chat_slack_manager_grants",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "slack_user_id": {
          "name": "slack_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "workspace_name": {
          "name": "workspace_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "manager_app_id": {
          "name": "manager_app_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "access_secret_id": {
          "name": "access_secret_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "refresh_secret_id": {
          "name": "refresh_secret_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "revision": {
          "name": "revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "rate_limits": {
          "name": "rate_limits",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_slack_manager_grants_company_id_idx": {
          "name": "chat_slack_manager_grants_company_id_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_slack_manager_grants_owner_idx": {
          "name": "chat_slack_manager_grants_owner_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "manager_app_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "workspace_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_slack_manager_grants_company_id_companies_id_fk": {
          "name": "chat_slack_manager_grants_company_id_companies_id_fk",
          "tableFrom": "chat_slack_manager_grants",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_slack_manager_grants_status_check": {
          "name": "chat_slack_manager_grants_status_check",
          "value": "\"chat_slack_manager_grants\".\"status\" in ('active', 'revoked', 'reauthorize')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_slack_registrations": {
      "name": "chat_slack_registrations",
      "schema": "",
      "columns": {
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "manager_grant_id": {
          "name": "manager_grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "request_id": {
          "name": "request_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "manifest": {
          "name": "manifest",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "manifest_hash": {
          "name": "manifest_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "callback_uri": {
          "name": "callback_uri",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "app_id": {
          "name": "app_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "client_id": {
          "name": "client_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "secret_ids": {
          "name": "secret_ids",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "bot_user_id": {
          "name": "bot_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "error_code": {
          "name": "error_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "chat_slack_registrations_company_id_manager_grant_id_chat_slack_manager_grants_company_id_id_fk": {
          "name": "chat_slack_registrations_company_id_manager_grant_id_chat_slack_manager_grants_company_id_id_fk",
          "tableFrom": "chat_slack_registrations",
          "tableTo": "chat_slack_manager_grants",
          "columnsFrom": [
            "company_id",
            "manager_grant_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_slack_registrations_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {
          "name": "chat_slack_registrations_company_id_endpoint_id_chat_endpoints_company_id_id_fk",
          "tableFrom": "chat_slack_registrations",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_slack_registration_status_check": {
          "name": "chat_slack_registration_status_check",
          "value": "\"chat_slack_registrations\".\"status\" in ('creating', 'uncertain', 'failed', 'install', 'credentials_saved', 'configured', 'removed')"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_teams_file_transfers": {
      "name": "chat_teams_file_transfers",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "publication_id": {
          "name": "publication_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "comment_id": {
          "name": "comment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "attachment_id": {
          "name": "attachment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "principal_id": {
          "name": "principal_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "authorized_user_id": {
          "name": "authorized_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "runtime_generation": {
          "name": "runtime_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "credential_fingerprint": {
          "name": "credential_fingerprint",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "conversation_generation": {
          "name": "conversation_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "source_digest": {
          "name": "source_digest",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "authority_digest": {
          "name": "authority_digest",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "tenant_id": {
          "name": "tenant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "bot_app_id": {
          "name": "bot_app_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "aad_object_id": {
          "name": "aad_object_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider_conversation_id": {
          "name": "provider_conversation_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider_user_id": {
          "name": "provider_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "sha256": {
          "name": "sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "byte_size": {
          "name": "byte_size",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "filename": {
          "name": "filename",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "token_sha256": {
          "name": "token_sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "phase": {
          "name": "phase",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'consent_pending'"
        },
        "version": {
          "name": "version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "attempt_id": {
          "name": "attempt_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "attempt_expires_at": {
          "name": "attempt_expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "consent_message_id": {
          "name": "consent_message_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "file_info_message_id": {
          "name": "file_info_message_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "response_activity_id": {
          "name": "response_activity_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "response_digest": {
          "name": "response_digest",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "private_state": {
          "name": "private_state",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "reason": {
          "name": "reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_teams_file_transfers_publication_uq": {
          "name": "chat_teams_file_transfers_publication_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "publication_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_teams_file_transfers_token_uq": {
          "name": "chat_teams_file_transfers_token_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "token_sha256",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_teams_file_transfers_work_idx": {
          "name": "chat_teams_file_transfers_work_idx",
          "columns": [
            {
              "expression": "phase",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "attempt_expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_teams_file_transfers_company_id_companies_id_fk": {
          "name": "chat_teams_file_transfers_company_id_companies_id_fk",
          "tableFrom": "chat_teams_file_transfers",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_teams_file_transfers_issue_id_issues_id_fk": {
          "name": "chat_teams_file_transfers_issue_id_issues_id_fk",
          "tableFrom": "chat_teams_file_transfers",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "chat_teams_file_transfers_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {
          "name": "chat_teams_file_transfers_company_id_endpoint_id_chat_endpoints_company_id_id_fk",
          "tableFrom": "chat_teams_file_transfers",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_teams_file_transfers_company_id_publication_id_chat_publications_company_id_id_fk": {
          "name": "chat_teams_file_transfers_company_id_publication_id_chat_publications_company_id_id_fk",
          "tableFrom": "chat_teams_file_transfers",
          "tableTo": "chat_publications",
          "columnsFrom": [
            "company_id",
            "publication_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_teams_file_transfers_company_id_conversation_id_chat_conversations_company_id_id_fk": {
          "name": "chat_teams_file_transfers_company_id_conversation_id_chat_conversations_company_id_id_fk",
          "tableFrom": "chat_teams_file_transfers",
          "tableTo": "chat_conversations",
          "columnsFrom": [
            "company_id",
            "conversation_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_teams_file_transfers_company_id_principal_id_chat_external_principals_company_id_id_fk": {
          "name": "chat_teams_file_transfers_company_id_principal_id_chat_external_principals_company_id_id_fk",
          "tableFrom": "chat_teams_file_transfers",
          "tableTo": "chat_external_principals",
          "columnsFrom": [
            "company_id",
            "principal_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_teams_file_transfers_phase_check": {
          "name": "chat_teams_file_transfers_phase_check",
          "value": "\"chat_teams_file_transfers\".\"phase\" in ('consent_pending','consent_sending','consent_unknown','awaiting_consent','upload_pending','uploading','upload_unknown','file_info_pending','file_info_sending','file_info_unknown','delivered','declined','expired','cancelled','conflict')"
        },
        "chat_teams_file_transfers_bounds_check": {
          "name": "chat_teams_file_transfers_bounds_check",
          "value": "\"chat_teams_file_transfers\".\"version\" > 0 and \"chat_teams_file_transfers\".\"runtime_generation\" >= 0 and \"chat_teams_file_transfers\".\"conversation_generation\" > 0 and \"chat_teams_file_transfers\".\"byte_size\" > 0 and \"chat_teams_file_transfers\".\"byte_size\" < 62914560"
        },
        "chat_teams_file_transfers_hash_check": {
          "name": "chat_teams_file_transfers_hash_check",
          "value": "\"chat_teams_file_transfers\".\"source_digest\" ~ '^[a-f0-9]{64}$' and \"chat_teams_file_transfers\".\"authority_digest\" ~ '^[a-f0-9]{64}$' and \"chat_teams_file_transfers\".\"sha256\" ~ '^[a-f0-9]{64}$' and \"chat_teams_file_transfers\".\"token_sha256\" ~ '^[a-f0-9]{64}$'"
        },
        "chat_teams_file_transfers_attempt_check": {
          "name": "chat_teams_file_transfers_attempt_check",
          "value": "(\"chat_teams_file_transfers\".\"attempt_id\" is null) = (\"chat_teams_file_transfers\".\"attempt_expires_at\" is null)"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_voice_callbacks": {
      "name": "chat_voice_callbacks",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "phone_number": {
          "name": "phone_number",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "enabled": {
          "name": "enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_voice_callbacks_owner_uq": {
          "name": "chat_voice_callbacks_owner_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_voice_callbacks_endpoint_fk": {
          "name": "chat_voice_callbacks_endpoint_fk",
          "tableFrom": "chat_voice_callbacks",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_voice_callbacks_phone_check": {
          "name": "chat_voice_callbacks_phone_check",
          "value": "\"chat_voice_callbacks\".\"phone_number\" ~ '^\\+[1-9][0-9]{6,14}$'"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_voice_inbound_calls": {
      "name": "chat_voice_inbound_calls",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider_session_id": {
          "name": "provider_session_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'awaiting_approval'"
        },
        "approval_code": {
          "name": "approval_code",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "generation": {
          "name": "generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "credential_fingerprint": {
          "name": "credential_fingerprint",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "tool_token_hash": {
          "name": "tool_token_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "request_fingerprint": {
          "name": "request_fingerprint",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "approved_by_user_id": {
          "name": "approved_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "caller_authority": {
          "name": "caller_authority",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "intake_issue_id": {
          "name": "intake_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "requested_issue_id": {
          "name": "requested_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "session_id": {
          "name": "session_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_voice_inbound_expiry_idx": {
          "name": "chat_voice_inbound_expiry_idx",
          "columns": [
            {
              "expression": "state",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_voice_inbound_endpoint_fk": {
          "name": "chat_voice_inbound_endpoint_fk",
          "tableFrom": "chat_voice_inbound_calls",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_voice_inbound_session_fk": {
          "name": "chat_voice_inbound_session_fk",
          "tableFrom": "chat_voice_inbound_calls",
          "tableTo": "chat_voice_sessions",
          "columnsFrom": [
            "company_id",
            "session_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_voice_inbound_intake_fk": {
          "name": "chat_voice_inbound_intake_fk",
          "tableFrom": "chat_voice_inbound_calls",
          "tableTo": "issues",
          "columnsFrom": [
            "company_id",
            "intake_issue_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_voice_inbound_requested_issue_fk": {
          "name": "chat_voice_inbound_requested_issue_fk",
          "tableFrom": "chat_voice_inbound_calls",
          "tableTo": "issues",
          "columnsFrom": [
            "company_id",
            "requested_issue_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "chat_voice_inbound_provider_uq": {
          "name": "chat_voice_inbound_provider_uq",
          "nullsNotDistinct": false,
          "columns": [
            "provider_session_id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "chat_voice_inbound_state_check": {
          "name": "chat_voice_inbound_state_check",
          "value": "\"chat_voice_inbound_calls\".\"state\" in ('guest_intake', 'awaiting_approval', 'approving', 'approved', 'denied', 'expired', 'ended')"
        },
        "chat_voice_inbound_token_check": {
          "name": "chat_voice_inbound_token_check",
          "value": "\"chat_voice_inbound_calls\".\"tool_token_hash\" ~ '^[a-f0-9]{64}$'"
        },
        "chat_voice_inbound_code_check": {
          "name": "chat_voice_inbound_code_check",
          "value": "\"chat_voice_inbound_calls\".\"approval_code\" ~ '^[0-9]{6}$'"
        },
        "chat_voice_inbound_generation_check": {
          "name": "chat_voice_inbound_generation_check",
          "value": "\"chat_voice_inbound_calls\".\"generation\" > 0"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_voice_phone_lines": {
      "name": "chat_voice_phone_lines",
      "schema": "",
      "columns": {
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider_number_id": {
          "name": "provider_number_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "phone_number": {
          "name": "phone_number",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "enabled": {
          "name": "enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "guest_intake": {
          "name": "guest_intake",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "low_trust_environment_id": {
          "name": "low_trust_environment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "chat_voice_phone_lines_low_trust_environment_id_environments_id_fk": {
          "name": "chat_voice_phone_lines_low_trust_environment_id_environments_id_fk",
          "tableFrom": "chat_voice_phone_lines",
          "tableTo": "environments",
          "columnsFrom": [
            "low_trust_environment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_voice_phone_lines_endpoint_fk": {
          "name": "chat_voice_phone_lines_endpoint_fk",
          "tableFrom": "chat_voice_phone_lines",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "chat_voice_phone_lines_number_uq": {
          "name": "chat_voice_phone_lines_number_uq",
          "nullsNotDistinct": false,
          "columns": [
            "provider_number_id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "chat_voice_phone_lines_number_check": {
          "name": "chat_voice_phone_lines_number_check",
          "value": "\"chat_voice_phone_lines\".\"phone_number\" ~ '^\\+[1-9][0-9]{6,14}$'"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_voice_reports": {
      "name": "chat_voice_reports",
      "schema": "",
      "columns": {
        "session_id": {
          "name": "session_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "transcript": {
          "name": "transcript",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "cost_micro_usd": {
          "name": "cost_micro_usd",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "duration_seconds": {
          "name": "duration_seconds",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "provider_updated_at": {
          "name": "provider_updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "next_check_at": {
          "name": "next_check_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "attempts": {
          "name": "attempts",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_voice_reports_pending_idx": {
          "name": "chat_voice_reports_pending_idx",
          "columns": [
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "next_check_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_voice_reports_session_fk": {
          "name": "chat_voice_reports_session_fk",
          "tableFrom": "chat_voice_reports",
          "tableTo": "chat_voice_sessions",
          "columnsFrom": [
            "company_id",
            "session_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_voice_reports_status_check": {
          "name": "chat_voice_reports_status_check",
          "value": "\"chat_voice_reports\".\"status\" in ('pending', 'available', 'unavailable')"
        },
        "chat_voice_reports_cost_check": {
          "name": "chat_voice_reports_cost_check",
          "value": "\"chat_voice_reports\".\"cost_micro_usd\" is null or \"chat_voice_reports\".\"cost_micro_usd\" ~ '^[0-9]{1,30}$'"
        },
        "chat_voice_reports_duration_check": {
          "name": "chat_voice_reports_duration_check",
          "value": "\"chat_voice_reports\".\"duration_seconds\" is null or \"chat_voice_reports\".\"duration_seconds\" >= 0"
        },
        "chat_voice_reports_attempts_check": {
          "name": "chat_voice_reports_attempts_check",
          "value": "\"chat_voice_reports\".\"attempts\" >= 0"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_voice_replies": {
      "name": "chat_voice_replies",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "session_id": {
          "name": "session_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "publication_id": {
          "name": "publication_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "cursor": {
          "name": "cursor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "delivered_at": {
          "name": "delivered_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "spoken_at": {
          "name": "spoken_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_voice_replies_publication_uq": {
          "name": "chat_voice_replies_publication_uq",
          "columns": [
            {
              "expression": "session_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "publication_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_voice_replies_cursor_uq": {
          "name": "chat_voice_replies_cursor_uq",
          "columns": [
            {
              "expression": "session_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "cursor",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_voice_replies_company_id_companies_id_fk": {
          "name": "chat_voice_replies_company_id_companies_id_fk",
          "tableFrom": "chat_voice_replies",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_voice_replies_session_fk": {
          "name": "chat_voice_replies_session_fk",
          "tableFrom": "chat_voice_replies",
          "tableTo": "chat_voice_sessions",
          "columnsFrom": [
            "company_id",
            "session_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_voice_replies_publication_fk": {
          "name": "chat_voice_replies_publication_fk",
          "tableFrom": "chat_voice_replies",
          "tableTo": "chat_publications",
          "columnsFrom": [
            "company_id",
            "publication_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_voice_replies_cursor_check": {
          "name": "chat_voice_replies_cursor_check",
          "value": "\"chat_voice_replies\".\"cursor\" > 0"
        },
        "chat_voice_replies_spoken_check": {
          "name": "chat_voice_replies_spoken_check",
          "value": "\"chat_voice_replies\".\"spoken_at\" is null or \"chat_voice_replies\".\"delivered_at\" is not null"
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_voice_sessions": {
      "name": "chat_voice_sessions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "assigned_agent_id": {
          "name": "assigned_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "caller_id": {
          "name": "caller_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "caller_authority": {
          "name": "caller_authority",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "approved_by_user_id": {
          "name": "approved_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "mode": {
          "name": "mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'reserved'"
        },
        "generation": {
          "name": "generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "credential_fingerprint": {
          "name": "credential_fingerprint",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider_session_id": {
          "name": "provider_session_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "tool_token_hash": {
          "name": "tool_token_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "request_fingerprint": {
          "name": "request_fingerprint",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "reply_cursor": {
          "name": "reply_cursor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "error_code": {
          "name": "error_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "ended_at": {
          "name": "ended_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_voice_sessions_provider_uq": {
          "name": "chat_voice_sessions_provider_uq",
          "columns": [
            {
              "expression": "provider_session_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_voice_sessions_request_uq": {
          "name": "chat_voice_sessions_request_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "caller_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_voice_sessions_live_caller_task_uq": {
          "name": "chat_voice_sessions_live_caller_task_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "caller_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"chat_voice_sessions\".\"state\" not in ('ended', 'failed', 'expired')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_voice_sessions_expiry_idx": {
          "name": "chat_voice_sessions_expiry_idx",
          "columns": [
            {
              "expression": "state",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_voice_sessions_company_id_companies_id_fk": {
          "name": "chat_voice_sessions_company_id_companies_id_fk",
          "tableFrom": "chat_voice_sessions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_voice_sessions_endpoint_fk": {
          "name": "chat_voice_sessions_endpoint_fk",
          "tableFrom": "chat_voice_sessions",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_voice_sessions_conversation_fk": {
          "name": "chat_voice_sessions_conversation_fk",
          "tableFrom": "chat_voice_sessions",
          "tableTo": "chat_conversations",
          "columnsFrom": [
            "company_id",
            "conversation_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_voice_sessions_issue_fk": {
          "name": "chat_voice_sessions_issue_fk",
          "tableFrom": "chat_voice_sessions",
          "tableTo": "issues",
          "columnsFrom": [
            "company_id",
            "issue_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_voice_sessions_agent_fk": {
          "name": "chat_voice_sessions_agent_fk",
          "tableFrom": "chat_voice_sessions",
          "tableTo": "agents",
          "columnsFrom": [
            "company_id",
            "assigned_agent_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "chat_voice_sessions_company_id_uq": {
          "name": "chat_voice_sessions_company_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "chat_voice_sessions_state_check": {
          "name": "chat_voice_sessions_state_check",
          "value": "\"chat_voice_sessions\".\"state\" in ('reserved', 'creating', 'creation_unknown', 'connecting', 'active', 'awaiting_approval', 'ending', 'ended', 'failed', 'expired')"
        },
        "chat_voice_sessions_mode_check": {
          "name": "chat_voice_sessions_mode_check",
          "value": "\"chat_voice_sessions\".\"mode\" in ('browser', 'inbound_phone', 'outbound_phone')"
        },
        "chat_voice_sessions_authority_check": {
          "name": "chat_voice_sessions_authority_check",
          "value": "\"chat_voice_sessions\".\"caller_authority\" in ('member', 'instance_admin', 'local_board', 'guest_intake', 'pending_approval')"
        },
        "chat_voice_sessions_counters_check": {
          "name": "chat_voice_sessions_counters_check",
          "value": "\"chat_voice_sessions\".\"generation\" >= 1 and \"chat_voice_sessions\".\"reply_cursor\" >= 0"
        },
        "chat_voice_sessions_token_check": {
          "name": "chat_voice_sessions_token_check",
          "value": "\"chat_voice_sessions\".\"tool_token_hash\" ~ '^[a-f0-9]{64}$'"
        },
        "chat_voice_sessions_expiry_check": {
          "name": "chat_voice_sessions_expiry_check",
          "value": "\"chat_voice_sessions\".\"expires_at\" > \"chat_voice_sessions\".\"created_at\""
        }
      },
      "isRLSEnabled": false
    },
    "public.chat_voice_tool_calls": {
      "name": "chat_voice_tool_calls",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "session_id": {
          "name": "session_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider_tool_call_id": {
          "name": "provider_tool_call_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "webhook_id": {
          "name": "webhook_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "fingerprint": {
          "name": "fingerprint",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "tool": {
          "name": "tool",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "delivery_id": {
          "name": "delivery_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "response": {
          "name": "response",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "chat_voice_tool_calls_tool_uq": {
          "name": "chat_voice_tool_calls_tool_uq",
          "columns": [
            {
              "expression": "session_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_tool_call_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "chat_voice_tool_calls_webhook_uq": {
          "name": "chat_voice_tool_calls_webhook_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "webhook_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "chat_voice_tool_calls_company_id_companies_id_fk": {
          "name": "chat_voice_tool_calls_company_id_companies_id_fk",
          "tableFrom": "chat_voice_tool_calls",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "chat_voice_tool_calls_session_fk": {
          "name": "chat_voice_tool_calls_session_fk",
          "tableFrom": "chat_voice_tool_calls",
          "tableTo": "chat_voice_sessions",
          "columnsFrom": [
            "company_id",
            "session_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "chat_voice_tool_calls_delivery_fk": {
          "name": "chat_voice_tool_calls_delivery_fk",
          "tableFrom": "chat_voice_tool_calls",
          "tableTo": "chat_deliveries",
          "columnsFrom": [
            "company_id",
            "delivery_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "chat_voice_tool_calls_tool_check": {
          "name": "chat_voice_tool_calls_tool_check",
          "value": "\"chat_voice_tool_calls\".\"tool\" in ('submit_request', 'get_updates', 'answer_question')"
        }
      },
      "isRLSEnabled": false
    },
    "public.cli_auth_challenges": {
      "name": "cli_auth_challenges",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "secret_hash": {
          "name": "secret_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "command": {
          "name": "command",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "client_name": {
          "name": "client_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "requested_access": {
          "name": "requested_access",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'board'"
        },
        "requested_company_id": {
          "name": "requested_company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "pending_key_hash": {
          "name": "pending_key_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "pending_key_name": {
          "name": "pending_key_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "approved_by_user_id": {
          "name": "approved_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "board_api_key_id": {
          "name": "board_api_key_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "approved_at": {
          "name": "approved_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "cancelled_at": {
          "name": "cancelled_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "cli_auth_challenges_secret_hash_idx": {
          "name": "cli_auth_challenges_secret_hash_idx",
          "columns": [
            {
              "expression": "secret_hash",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cli_auth_challenges_approved_by_idx": {
          "name": "cli_auth_challenges_approved_by_idx",
          "columns": [
            {
              "expression": "approved_by_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cli_auth_challenges_requested_company_idx": {
          "name": "cli_auth_challenges_requested_company_idx",
          "columns": [
            {
              "expression": "requested_company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "cli_auth_challenges_requested_company_id_companies_id_fk": {
          "name": "cli_auth_challenges_requested_company_id_companies_id_fk",
          "tableFrom": "cli_auth_challenges",
          "tableTo": "companies",
          "columnsFrom": [
            "requested_company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "cli_auth_challenges_approved_by_user_id_user_id_fk": {
          "name": "cli_auth_challenges_approved_by_user_id_user_id_fk",
          "tableFrom": "cli_auth_challenges",
          "tableTo": "user",
          "columnsFrom": [
            "approved_by_user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "cli_auth_challenges_board_api_key_id_board_api_keys_id_fk": {
          "name": "cli_auth_challenges_board_api_key_id_board_api_keys_id_fk",
          "tableFrom": "cli_auth_challenges",
          "tableTo": "board_api_keys",
          "columnsFrom": [
            "board_api_key_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.companies": {
      "name": "companies",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "pause_reason": {
          "name": "pause_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "paused_at": {
          "name": "paused_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "issue_prefix": {
          "name": "issue_prefix",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'PAP'"
        },
        "issue_counter": {
          "name": "issue_counter",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "budget_monthly_cents": {
          "name": "budget_monthly_cents",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "spend_month_utc": {
          "name": "spend_month_utc",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "spent_monthly_cents": {
          "name": "spent_monthly_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "default_responsible_user_id": {
          "name": "default_responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "require_board_approval_for_new_agents": {
          "name": "require_board_approval_for_new_agents",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "interaction_resolver_governance": {
          "name": "interaction_resolver_governance",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "feedback_data_sharing_enabled": {
          "name": "feedback_data_sharing_enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "feedback_data_sharing_consent_at": {
          "name": "feedback_data_sharing_consent_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "feedback_data_sharing_consent_by_user_id": {
          "name": "feedback_data_sharing_consent_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "feedback_data_sharing_terms_version": {
          "name": "feedback_data_sharing_terms_version",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "companies_issue_prefix_idx": {
          "name": "companies_issue_prefix_idx",
          "columns": [
            {
              "expression": "issue_prefix",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_logos": {
      "name": "company_logos",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "asset_id": {
          "name": "asset_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_logos_company_uq": {
          "name": "company_logos_company_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_logos_asset_uq": {
          "name": "company_logos_asset_uq",
          "columns": [
            {
              "expression": "asset_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_logos_company_id_companies_id_fk": {
          "name": "company_logos_company_id_companies_id_fk",
          "tableFrom": "company_logos",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_logos_asset_id_assets_id_fk": {
          "name": "company_logos_asset_id_assets_id_fk",
          "tableFrom": "company_logos",
          "tableTo": "assets",
          "columnsFrom": [
            "asset_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_memberships": {
      "name": "company_memberships",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "principal_type": {
          "name": "principal_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "principal_id": {
          "name": "principal_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "membership_role": {
          "name": "membership_role",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_memberships_company_principal_unique_idx": {
          "name": "company_memberships_company_principal_unique_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "principal_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "principal_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_memberships_principal_status_idx": {
          "name": "company_memberships_principal_status_idx",
          "columns": [
            {
              "expression": "principal_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "principal_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_memberships_company_status_idx": {
          "name": "company_memberships_company_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_memberships_company_id_companies_id_fk": {
          "name": "company_memberships_company_id_companies_id_fk",
          "tableFrom": "company_memberships",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_observability": {
      "name": "company_observability",
      "schema": "",
      "columns": {
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "revision": {
          "name": "revision",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "enabled": {
          "name": "enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "destination": {
          "name": "destination",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "capture": {
          "name": "capture",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "credentials_secret_id": {
          "name": "credentials_secret_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "header_names": {
          "name": "header_names",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "last_test": {
          "name": "last_test",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "company_observability_company_id_companies_id_fk": {
          "name": "company_observability_company_id_companies_id_fk",
          "tableFrom": "company_observability",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_observability_credentials_secret_id_company_secrets_id_fk": {
          "name": "company_observability_credentials_secret_id_company_secrets_id_fk",
          "tableFrom": "company_observability",
          "tableTo": "company_secrets",
          "columnsFrom": [
            "credentials_secret_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_onboarding_seeds": {
      "name": "company_onboarding_seeds",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "revision": {
          "name": "revision",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "mission": {
          "name": "mission",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "agent_name": {
          "name": "agent_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "agent_role": {
          "name": "agent_role",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "first_task_title": {
          "name": "first_task_title",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "first_task_details": {
          "name": "first_task_details",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "goal_id": {
          "name": "goal_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "applied_at": {
          "name": "applied_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_onboarding_seeds_company_uq": {
          "name": "company_onboarding_seeds_company_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_onboarding_seeds_company_id_companies_id_fk": {
          "name": "company_onboarding_seeds_company_id_companies_id_fk",
          "tableFrom": "company_onboarding_seeds",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_onboarding_seeds_goal_id_goals_id_fk": {
          "name": "company_onboarding_seeds_goal_id_goals_id_fk",
          "tableFrom": "company_onboarding_seeds",
          "tableTo": "goals",
          "columnsFrom": [
            "goal_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_onboarding_seeds_agent_id_agents_id_fk": {
          "name": "company_onboarding_seeds_agent_id_agents_id_fk",
          "tableFrom": "company_onboarding_seeds",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_onboarding_seeds_issue_id_issues_id_fk": {
          "name": "company_onboarding_seeds_issue_id_issues_id_fk",
          "tableFrom": "company_onboarding_seeds",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_secret_bindings": {
      "name": "company_secret_bindings",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "secret_id": {
          "name": "secret_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "target_type": {
          "name": "target_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "target_id": {
          "name": "target_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "config_path": {
          "name": "config_path",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "version_selector": {
          "name": "version_selector",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'latest'"
        },
        "required": {
          "name": "required",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "label": {
          "name": "label",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "projection_class": {
          "name": "projection_class",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'unclassified'"
        },
        "projection_allowlist_key": {
          "name": "projection_allowlist_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_secret_bindings_company_idx": {
          "name": "company_secret_bindings_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_bindings_secret_idx": {
          "name": "company_secret_bindings_secret_idx",
          "columns": [
            {
              "expression": "secret_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_bindings_target_idx": {
          "name": "company_secret_bindings_target_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "target_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "target_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_bindings_target_path_uq": {
          "name": "company_secret_bindings_target_path_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "target_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "target_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "config_path",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_secret_bindings_company_id_companies_id_fk": {
          "name": "company_secret_bindings_company_id_companies_id_fk",
          "tableFrom": "company_secret_bindings",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "company_secret_bindings_secret_id_company_secrets_id_fk": {
          "name": "company_secret_bindings_secret_id_company_secrets_id_fk",
          "tableFrom": "company_secret_bindings",
          "tableTo": "company_secrets",
          "columnsFrom": [
            "secret_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_secret_proposals": {
      "name": "company_secret_proposals",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "proposed_name": {
          "name": "proposed_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "proposed_key": {
          "name": "proposed_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "proposed_description": {
          "name": "proposed_description",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "justification": {
          "name": "justification",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "value_ciphertext": {
          "name": "value_ciphertext",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "value_fingerprint_sha256": {
          "name": "value_fingerprint_sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "value_length": {
          "name": "value_length",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "secret_id": {
          "name": "secret_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "secret_proposal_id": {
          "name": "secret_proposal_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "target_type": {
          "name": "target_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "target_id": {
          "name": "target_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "config_path": {
          "name": "config_path",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "projection_class": {
          "name": "projection_class",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'unclassified'"
        },
        "binding_target_policy_snapshot": {
          "name": "binding_target_policy_snapshot",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "proposer_ancestor_ids_snapshot": {
          "name": "proposer_ancestor_ids_snapshot",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "target_ancestor_ids_snapshot": {
          "name": "target_ancestor_ids_snapshot",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "proposed_by_agent_id": {
          "name": "proposed_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "origin_issue_id": {
          "name": "origin_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "origin_run_id": {
          "name": "origin_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "interaction_id": {
          "name": "interaction_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "resolved_by_user_id": {
          "name": "resolved_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "resolved_at": {
          "name": "resolved_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "resolution_reason": {
          "name": "resolution_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_secret_id": {
          "name": "created_secret_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "applied_binding_config_path": {
          "name": "applied_binding_config_path",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "ciphertext_scrubbed_at": {
          "name": "ciphertext_scrubbed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_secret_proposals_company_status_idx": {
          "name": "company_secret_proposals_company_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_proposals_proposer_status_idx": {
          "name": "company_secret_proposals_proposer_status_idx",
          "columns": [
            {
              "expression": "proposed_by_agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_proposals_expiry_idx": {
          "name": "company_secret_proposals_expiry_idx",
          "columns": [
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_proposals_secret_proposal_idx": {
          "name": "company_secret_proposals_secret_proposal_idx",
          "columns": [
            {
              "expression": "secret_proposal_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_proposals_interaction_idx": {
          "name": "company_secret_proposals_interaction_idx",
          "columns": [
            {
              "expression": "interaction_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_secret_proposals_company_id_companies_id_fk": {
          "name": "company_secret_proposals_company_id_companies_id_fk",
          "tableFrom": "company_secret_proposals",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "company_secret_proposals_secret_id_company_secrets_id_fk": {
          "name": "company_secret_proposals_secret_id_company_secrets_id_fk",
          "tableFrom": "company_secret_proposals",
          "tableTo": "company_secrets",
          "columnsFrom": [
            "secret_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_secret_proposals_secret_proposal_id_company_secret_proposals_id_fk": {
          "name": "company_secret_proposals_secret_proposal_id_company_secret_proposals_id_fk",
          "tableFrom": "company_secret_proposals",
          "tableTo": "company_secret_proposals",
          "columnsFrom": [
            "secret_proposal_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_secret_proposals_target_id_agents_id_fk": {
          "name": "company_secret_proposals_target_id_agents_id_fk",
          "tableFrom": "company_secret_proposals",
          "tableTo": "agents",
          "columnsFrom": [
            "target_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_secret_proposals_proposed_by_agent_id_agents_id_fk": {
          "name": "company_secret_proposals_proposed_by_agent_id_agents_id_fk",
          "tableFrom": "company_secret_proposals",
          "tableTo": "agents",
          "columnsFrom": [
            "proposed_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_secret_proposals_origin_issue_id_issues_id_fk": {
          "name": "company_secret_proposals_origin_issue_id_issues_id_fk",
          "tableFrom": "company_secret_proposals",
          "tableTo": "issues",
          "columnsFrom": [
            "origin_issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_secret_proposals_origin_run_id_heartbeat_runs_id_fk": {
          "name": "company_secret_proposals_origin_run_id_heartbeat_runs_id_fk",
          "tableFrom": "company_secret_proposals",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "origin_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_secret_proposals_interaction_id_issue_thread_interactions_id_fk": {
          "name": "company_secret_proposals_interaction_id_issue_thread_interactions_id_fk",
          "tableFrom": "company_secret_proposals",
          "tableTo": "issue_thread_interactions",
          "columnsFrom": [
            "interaction_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_secret_proposals_created_secret_id_company_secrets_id_fk": {
          "name": "company_secret_proposals_created_secret_id_company_secrets_id_fk",
          "tableFrom": "company_secret_proposals",
          "tableTo": "company_secrets",
          "columnsFrom": [
            "created_secret_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "company_secret_proposals_kind_check": {
          "name": "company_secret_proposals_kind_check",
          "value": "\"company_secret_proposals\".\"kind\" in ('secret', 'binding')"
        },
        "company_secret_proposals_status_check": {
          "name": "company_secret_proposals_status_check",
          "value": "\"company_secret_proposals\".\"status\" in ('pending', 'approved', 'rejected', 'withdrawn', 'expired')"
        },
        "company_secret_proposals_projection_check": {
          "name": "company_secret_proposals_projection_check",
          "value": "\"company_secret_proposals\".\"projection_class\" = 'unclassified'"
        },
        "company_secret_proposals_shape_check": {
          "name": "company_secret_proposals_shape_check",
          "value": "(\n      \"company_secret_proposals\".\"kind\" = 'secret'\n      and \"company_secret_proposals\".\"proposed_name\" is not null\n      and \"company_secret_proposals\".\"proposed_key\" is not null\n      and \"company_secret_proposals\".\"secret_id\" is null\n      and \"company_secret_proposals\".\"secret_proposal_id\" is null\n      and \"company_secret_proposals\".\"target_type\" is null\n      and \"company_secret_proposals\".\"target_id\" is null\n      and \"company_secret_proposals\".\"config_path\" is null\n    ) or (\n      \"company_secret_proposals\".\"kind\" = 'binding'\n      and ((\"company_secret_proposals\".\"secret_id\" is not null)::int + (\"company_secret_proposals\".\"secret_proposal_id\" is not null)::int) = 1\n      and \"company_secret_proposals\".\"target_type\" = 'agent'\n      and \"company_secret_proposals\".\"target_id\" is not null\n      and \"company_secret_proposals\".\"config_path\" is not null\n    )"
        }
      },
      "isRLSEnabled": false
    },
    "public.company_secret_provider_configs": {
      "name": "company_secret_provider_configs",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "display_name": {
          "name": "display_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'ready'"
        },
        "is_default": {
          "name": "is_default",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "config": {
          "name": "config",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "health_status": {
          "name": "health_status",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "health_checked_at": {
          "name": "health_checked_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "health_message": {
          "name": "health_message",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "health_details": {
          "name": "health_details",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "disabled_at": {
          "name": "disabled_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_secret_provider_configs_company_idx": {
          "name": "company_secret_provider_configs_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_provider_configs_company_provider_idx": {
          "name": "company_secret_provider_configs_company_provider_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_provider_configs_default_uq": {
          "name": "company_secret_provider_configs_default_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"company_secret_provider_configs\".\"is_default\" = true",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_secret_provider_configs_company_id_companies_id_fk": {
          "name": "company_secret_provider_configs_company_id_companies_id_fk",
          "tableFrom": "company_secret_provider_configs",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_secret_provider_configs_created_by_agent_id_agents_id_fk": {
          "name": "company_secret_provider_configs_created_by_agent_id_agents_id_fk",
          "tableFrom": "company_secret_provider_configs",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_secret_versions": {
      "name": "company_secret_versions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "secret_id": {
          "name": "secret_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "version": {
          "name": "version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "material": {
          "name": "material",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "value_sha256": {
          "name": "value_sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider_version_ref": {
          "name": "provider_version_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'current'"
        },
        "fingerprint_sha256": {
          "name": "fingerprint_sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "rotation_job_id": {
          "name": "rotation_job_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "revoked_at": {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {
        "company_secret_versions_secret_idx": {
          "name": "company_secret_versions_secret_idx",
          "columns": [
            {
              "expression": "secret_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_versions_value_sha256_idx": {
          "name": "company_secret_versions_value_sha256_idx",
          "columns": [
            {
              "expression": "value_sha256",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_versions_fingerprint_idx": {
          "name": "company_secret_versions_fingerprint_idx",
          "columns": [
            {
              "expression": "fingerprint_sha256",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secret_versions_secret_version_uq": {
          "name": "company_secret_versions_secret_version_uq",
          "columns": [
            {
              "expression": "secret_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "version",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_secret_versions_secret_id_company_secrets_id_fk": {
          "name": "company_secret_versions_secret_id_company_secrets_id_fk",
          "tableFrom": "company_secret_versions",
          "tableTo": "company_secrets",
          "columnsFrom": [
            "secret_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_secret_versions_created_by_agent_id_agents_id_fk": {
          "name": "company_secret_versions_created_by_agent_id_agents_id_fk",
          "tableFrom": "company_secret_versions",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_secrets": {
      "name": "company_secrets",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "scope": {
          "name": "scope",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'company'"
        },
        "owner_user_id": {
          "name": "owner_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "owner_agent_id": {
          "name": "owner_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "owner_project_id": {
          "name": "owner_project_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "owner_plugin_id": {
          "name": "owner_plugin_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "user_secret_definition_id": {
          "name": "user_secret_definition_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'local_encrypted'"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "managed_mode": {
          "name": "managed_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'paperclip_managed'"
        },
        "external_ref": {
          "name": "external_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "provider_config_id": {
          "name": "provider_config_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "provider_metadata": {
          "name": "provider_metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "ai_session_epoch": {
          "name": "ai_session_epoch",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "latest_version": {
          "name": "latest_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "last_resolved_at": {
          "name": "last_resolved_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_rotated_at": {
          "name": "last_rotated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "deleted_at": {
          "name": "deleted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_secrets_company_idx": {
          "name": "company_secrets_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secrets_company_scope_idx": {
          "name": "company_secrets_company_scope_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "scope",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secrets_company_owner_idx": {
          "name": "company_secrets_company_owner_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "owner_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secrets_user_definition_owner_idx": {
          "name": "company_secrets_user_definition_owner_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_secret_definition_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "owner_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secrets_company_provider_idx": {
          "name": "company_secrets_company_provider_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secrets_project_instance_owner_key_uq": {
          "name": "company_secrets_project_instance_owner_key_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "owner_project_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "owner_plugin_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"company_secrets\".\"scope\" = 'instance' and \"company_secrets\".\"deleted_at\" is null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secrets_instance_owner_key_uq": {
          "name": "company_secrets_instance_owner_key_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "owner_agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "owner_plugin_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"company_secrets\".\"scope\" = 'instance' and \"company_secrets\".\"deleted_at\" is null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secrets_provider_config_idx": {
          "name": "company_secrets_provider_config_idx",
          "columns": [
            {
              "expression": "provider_config_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secrets_company_name_uq": {
          "name": "company_secrets_company_name_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "name",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"company_secrets\".\"scope\" = 'company' and \"company_secrets\".\"deleted_at\" is null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secrets_company_key_uq": {
          "name": "company_secrets_company_key_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"company_secrets\".\"scope\" = 'company' and \"company_secrets\".\"deleted_at\" is null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_secrets_user_definition_owner_uq": {
          "name": "company_secrets_user_definition_owner_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_secret_definition_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "owner_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"company_secrets\".\"scope\" = 'user' and \"company_secrets\".\"deleted_at\" is null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_secrets_company_id_companies_id_fk": {
          "name": "company_secrets_company_id_companies_id_fk",
          "tableFrom": "company_secrets",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "company_secrets_owner_plugin_id_plugins_id_fk": {
          "name": "company_secrets_owner_plugin_id_plugins_id_fk",
          "tableFrom": "company_secrets",
          "tableTo": "plugins",
          "columnsFrom": [
            "owner_plugin_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_secrets_user_secret_definition_id_user_secret_definitions_id_fk": {
          "name": "company_secrets_user_secret_definition_id_user_secret_definitions_id_fk",
          "tableFrom": "company_secrets",
          "tableTo": "user_secret_definitions",
          "columnsFrom": [
            "user_secret_definition_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_secrets_provider_config_id_company_secret_provider_configs_id_fk": {
          "name": "company_secrets_provider_config_id_company_secret_provider_configs_id_fk",
          "tableFrom": "company_secrets",
          "tableTo": "company_secret_provider_configs",
          "columnsFrom": [
            "provider_config_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_secrets_created_by_agent_id_agents_id_fk": {
          "name": "company_secrets_created_by_agent_id_agents_id_fk",
          "tableFrom": "company_secrets",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_secrets_company_id_owner_agent_id_agents_company_id_id_fk": {
          "name": "company_secrets_company_id_owner_agent_id_agents_company_id_id_fk",
          "tableFrom": "company_secrets",
          "tableTo": "agents",
          "columnsFrom": [
            "company_id",
            "owner_agent_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_secrets_company_id_owner_project_id_projects_company_id_id_fk": {
          "name": "company_secrets_company_id_owner_project_id_projects_company_id_id_fk",
          "tableFrom": "company_secrets",
          "tableTo": "projects",
          "columnsFrom": [
            "company_id",
            "owner_project_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "company_secrets_scope_shape_check": {
          "name": "company_secrets_scope_shape_check",
          "value": "(\n        \"company_secrets\".\"scope\" = 'company'\n        and \"company_secrets\".\"owner_user_id\" is null\n        and \"company_secrets\".\"user_secret_definition_id\" is null\n        and \"company_secrets\".\"owner_agent_id\" is null and \"company_secrets\".\"owner_project_id\" is null and \"company_secrets\".\"owner_plugin_id\" is null\n      ) or (\n        \"company_secrets\".\"scope\" = 'user'\n        and \"company_secrets\".\"owner_user_id\" is not null\n        and \"company_secrets\".\"user_secret_definition_id\" is not null\n        and \"company_secrets\".\"owner_agent_id\" is null and \"company_secrets\".\"owner_project_id\" is null and \"company_secrets\".\"owner_plugin_id\" is null\n      ) or (\n        \"company_secrets\".\"scope\" = 'instance'\n        and \"company_secrets\".\"owner_user_id\" is null and \"company_secrets\".\"user_secret_definition_id\" is null\n        and (\"company_secrets\".\"owner_agent_id\" is not null) <> (\"company_secrets\".\"owner_project_id\" is not null)\n        and \"company_secrets\".\"owner_plugin_id\" is not null\n      )"
        }
      },
      "isRLSEnabled": false
    },
    "public.company_skill_policies": {
      "name": "company_skill_policies",
      "schema": "",
      "columns": {
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "schema_version": {
          "name": "schema_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "revision": {
          "name": "revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "default_effect": {
          "name": "default_effect",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "rules": {
          "name": "rules",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "company_skill_policies_company_id_companies_id_fk": {
          "name": "company_skill_policies_company_id_companies_id_fk",
          "tableFrom": "company_skill_policies",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_skill_import_budgets": {
      "name": "company_skill_import_budgets",
      "schema": "",
      "columns": {
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "available_bytes": {
          "name": "available_bytes",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 536870912
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "company_skill_import_budgets_company_id_companies_id_fk": {
          "name": "company_skill_import_budgets_company_id_companies_id_fk",
          "tableFrom": "company_skill_import_budgets",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_skill_source_entries": {
      "name": "company_skill_source_entries",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_id": {
          "name": "source_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "path": {
          "name": "path",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "inspection": {
          "name": "inspection",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "skill_id": {
          "name": "skill_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "selection": {
          "name": "selection",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'new'"
        },
        "present": {
          "name": "present",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "error": {
          "name": "error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {
        "company_skill_source_entries_source_path_idx": {
          "name": "company_skill_source_entries_source_path_idx",
          "columns": [
            {
              "expression": "source_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "path",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_source_entries_company_skill_idx": {
          "name": "company_skill_source_entries_company_skill_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_skill_source_entries_company_id_companies_id_fk": {
          "name": "company_skill_source_entries_company_id_companies_id_fk",
          "tableFrom": "company_skill_source_entries",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_source_entries_source_id_company_skill_sources_id_fk": {
          "name": "company_skill_source_entries_source_id_company_skill_sources_id_fk",
          "tableFrom": "company_skill_source_entries",
          "tableTo": "company_skill_sources",
          "columnsFrom": [
            "source_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_source_entries_skill_id_company_skills_id_fk": {
          "name": "company_skill_source_entries_skill_id_company_skills_id_fk",
          "tableFrom": "company_skill_source_entries",
          "tableTo": "company_skills",
          "columnsFrom": [
            "skill_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_skill_sources": {
      "name": "company_skill_sources",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "repository_id": {
          "name": "repository_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "repository_url": {
          "name": "repository_url",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "full_name": {
          "name": "full_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "tracking_ref": {
          "name": "tracking_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "package_mode": {
          "name": "package_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'skills'"
        },
        "repository_package": {
          "name": "repository_package",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "excluded_folders": {
          "name": "excluded_folders",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "enabled": {
          "name": "enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "removed_at": {
          "name": "removed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "automatic_updates": {
          "name": "automatic_updates",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "import_new_skills": {
          "name": "import_new_skills",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "access_scope": {
          "name": "access_scope",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'company'"
        },
        "refresh_user_id": {
          "name": "refresh_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "refresh_agent_id": {
          "name": "refresh_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "refresh_local_trusted": {
          "name": "refresh_local_trusted",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "refresh_grant_id": {
          "name": "refresh_grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "next_sync_at": {
          "name": "next_sync_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "failure_count": {
          "name": "failure_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "revision": {
          "name": "revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "last_attempt_at": {
          "name": "last_attempt_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_success_at": {
          "name": "last_success_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_scan_commit": {
          "name": "last_scan_commit",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "last_scan_tree_sha": {
          "name": "last_scan_tree_sha",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "automatic_budget_bytes": {
          "name": "automatic_budget_bytes",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 536870912
        },
        "automatic_budget_at": {
          "name": "automatic_budget_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "last_error": {
          "name": "last_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "lease_token": {
          "name": "lease_token",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "lease_expires_at": {
          "name": "lease_expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_skill_sources_repository_ref_idx": {
          "name": "company_skill_sources_repository_ref_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "repository_url",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "tracking_ref",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"company_skill_sources\".\"removed_at\" is null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_sources_identity_ref_idx": {
          "name": "company_skill_sources_identity_ref_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "repository_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "tracking_ref",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"company_skill_sources\".\"removed_at\" is null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_skill_sources_company_id_companies_id_fk": {
          "name": "company_skill_sources_company_id_companies_id_fk",
          "tableFrom": "company_skill_sources",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.project_skill_sources": {
      "name": "project_skill_sources",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "project_id": {
          "name": "project_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "source_id": {
          "name": "source_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "repository_url": {
          "name": "repository_url",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "tracking_ref": {
          "name": "tracking_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "active": {
          "name": "active",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "refresh_user_id": {
          "name": "refresh_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "refresh_agent_id": {
          "name": "refresh_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "refresh_local_trusted": {
          "name": "refresh_local_trusted",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "refresh_grant_id": {
          "name": "refresh_grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "next_sync_at": {
          "name": "next_sync_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "failure_count": {
          "name": "failure_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "last_error": {
          "name": "last_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "lease_token": {
          "name": "lease_token",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "lease_expires_at": {
          "name": "lease_expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "project_skill_sources_workspace_repo_ref_idx": {
          "name": "project_skill_sources_workspace_repo_ref_idx",
          "columns": [
            {
              "expression": "workspace_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "repository_url",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "tracking_ref",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "project_skill_sources_source_project_idx": {
          "name": "project_skill_sources_source_project_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "project_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "project_skill_sources_sync_idx": {
          "name": "project_skill_sources_sync_idx",
          "columns": [
            {
              "expression": "active",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "next_sync_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "project_skill_sources_company_id_companies_id_fk": {
          "name": "project_skill_sources_company_id_companies_id_fk",
          "tableFrom": "project_skill_sources",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "project_skill_sources_project_id_projects_id_fk": {
          "name": "project_skill_sources_project_id_projects_id_fk",
          "tableFrom": "project_skill_sources",
          "tableTo": "projects",
          "columnsFrom": [
            "project_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "project_skill_sources_workspace_id_project_workspaces_id_fk": {
          "name": "project_skill_sources_workspace_id_project_workspaces_id_fk",
          "tableFrom": "project_skill_sources",
          "tableTo": "project_workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "project_skill_sources_source_id_company_skill_sources_id_fk": {
          "name": "project_skill_sources_source_id_company_skill_sources_id_fk",
          "tableFrom": "project_skill_sources",
          "tableTo": "company_skill_sources",
          "columnsFrom": [
            "source_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_skill_comments": {
      "name": "company_skill_comments",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "company_skill_id": {
          "name": "company_skill_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "parent_comment_id": {
          "name": "parent_comment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "author_agent_id": {
          "name": "author_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "author_user_id": {
          "name": "author_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "body": {
          "name": "body",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "deleted_at": {
          "name": "deleted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_skill_comments_company_skill_created_idx": {
          "name": "company_skill_comments_company_skill_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "company_skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_comments_parent_idx": {
          "name": "company_skill_comments_parent_idx",
          "columns": [
            {
              "expression": "parent_comment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_skill_comments_company_id_companies_id_fk": {
          "name": "company_skill_comments_company_id_companies_id_fk",
          "tableFrom": "company_skill_comments",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_comments_company_skill_id_company_skills_id_fk": {
          "name": "company_skill_comments_company_skill_id_company_skills_id_fk",
          "tableFrom": "company_skill_comments",
          "tableTo": "company_skills",
          "columnsFrom": [
            "company_skill_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_comments_parent_comment_id_company_skill_comments_id_fk": {
          "name": "company_skill_comments_parent_comment_id_company_skill_comments_id_fk",
          "tableFrom": "company_skill_comments",
          "tableTo": "company_skill_comments",
          "columnsFrom": [
            "parent_comment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_skill_comments_author_agent_id_agents_id_fk": {
          "name": "company_skill_comments_author_agent_id_agents_id_fk",
          "tableFrom": "company_skill_comments",
          "tableTo": "agents",
          "columnsFrom": [
            "author_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_skill_repository_snapshots": {
      "name": "company_skill_repository_snapshots",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "content_hash": {
          "name": "content_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "file_inventory": {
          "name": "file_inventory",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_skill_repository_snapshots_content_idx": {
          "name": "company_skill_repository_snapshots_content_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "content_hash",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_skill_repository_snapshots_company_id_companies_id_fk": {
          "name": "company_skill_repository_snapshots_company_id_companies_id_fk",
          "tableFrom": "company_skill_repository_snapshots",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_skill_stars": {
      "name": "company_skill_stars",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "company_skill_id": {
          "name": "company_skill_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_skill_stars_skill_agent_idx": {
          "name": "company_skill_stars_skill_agent_idx",
          "columns": [
            {
              "expression": "company_skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_stars_skill_user_idx": {
          "name": "company_skill_stars_skill_user_idx",
          "columns": [
            {
              "expression": "company_skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_stars_company_skill_created_idx": {
          "name": "company_skill_stars_company_skill_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "company_skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_skill_stars_company_id_companies_id_fk": {
          "name": "company_skill_stars_company_id_companies_id_fk",
          "tableFrom": "company_skill_stars",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_stars_company_skill_id_company_skills_id_fk": {
          "name": "company_skill_stars_company_skill_id_company_skills_id_fk",
          "tableFrom": "company_skill_stars",
          "tableTo": "company_skills",
          "columnsFrom": [
            "company_skill_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_stars_agent_id_agents_id_fk": {
          "name": "company_skill_stars_agent_id_agents_id_fk",
          "tableFrom": "company_skill_stars",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_skill_test_inputs": {
      "name": "company_skill_test_inputs",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "skill_id": {
          "name": "skill_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "content": {
          "name": "content",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_by": {
          "name": "created_by",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "deleted_at": {
          "name": "deleted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_skill_test_inputs_company_skill_name_idx": {
          "name": "company_skill_test_inputs_company_skill_name_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "name",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_test_inputs_company_skill_active_idx": {
          "name": "company_skill_test_inputs_company_skill_active_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "deleted_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_skill_test_inputs_company_id_companies_id_fk": {
          "name": "company_skill_test_inputs_company_id_companies_id_fk",
          "tableFrom": "company_skill_test_inputs",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_test_inputs_skill_id_company_skills_id_fk": {
          "name": "company_skill_test_inputs_skill_id_company_skills_id_fk",
          "tableFrom": "company_skill_test_inputs",
          "tableTo": "company_skills",
          "columnsFrom": [
            "skill_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_skill_test_run_templates": {
      "name": "company_skill_test_run_templates",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "body": {
          "name": "body",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "updated_by_agent_id": {
          "name": "updated_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "updated_by_user_id": {
          "name": "updated_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "deleted_at": {
          "name": "deleted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_skill_test_run_templates_company_active_idx": {
          "name": "company_skill_test_run_templates_company_active_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "deleted_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "name",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_skill_test_run_templates_company_id_companies_id_fk": {
          "name": "company_skill_test_run_templates_company_id_companies_id_fk",
          "tableFrom": "company_skill_test_run_templates",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_test_run_templates_created_by_agent_id_agents_id_fk": {
          "name": "company_skill_test_run_templates_created_by_agent_id_agents_id_fk",
          "tableFrom": "company_skill_test_run_templates",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_skill_test_run_templates_updated_by_agent_id_agents_id_fk": {
          "name": "company_skill_test_run_templates_updated_by_agent_id_agents_id_fk",
          "tableFrom": "company_skill_test_run_templates",
          "tableTo": "agents",
          "columnsFrom": [
            "updated_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_skill_test_runs": {
      "name": "company_skill_test_runs",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "skill_id": {
          "name": "skill_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "input_id": {
          "name": "input_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "input_snapshot": {
          "name": "input_snapshot",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "skill_version_id": {
          "name": "skill_version_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_config_snapshot": {
          "name": "agent_config_snapshot",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "template_id": {
          "name": "template_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "template_name": {
          "name": "template_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "template_body": {
          "name": "template_body",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "rendered_template_body": {
          "name": "rendered_template_body",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "harness_issue_description": {
          "name": "harness_issue_description",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "''"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'queued'"
        },
        "output_document_key": {
          "name": "output_document_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'output'"
        },
        "output_snapshot": {
          "name": "output_snapshot",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "''"
        },
        "error": {
          "name": "error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "deleted_at": {
          "name": "deleted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "superseded_at": {
          "name": "superseded_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "harness_issue_expires_at": {
          "name": "harness_issue_expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "harness_issue_deleted_at": {
          "name": "harness_issue_deleted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_skill_test_runs_company_skill_created_idx": {
          "name": "company_skill_test_runs_company_skill_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_test_runs_company_issue_idx": {
          "name": "company_skill_test_runs_company_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_test_runs_company_input_created_idx": {
          "name": "company_skill_test_runs_company_input_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "input_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_test_runs_company_status_idx": {
          "name": "company_skill_test_runs_company_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_test_runs_company_harness_expires_idx": {
          "name": "company_skill_test_runs_company_harness_expires_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "harness_issue_expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_skill_test_runs_company_id_companies_id_fk": {
          "name": "company_skill_test_runs_company_id_companies_id_fk",
          "tableFrom": "company_skill_test_runs",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_test_runs_skill_id_company_skills_id_fk": {
          "name": "company_skill_test_runs_skill_id_company_skills_id_fk",
          "tableFrom": "company_skill_test_runs",
          "tableTo": "company_skills",
          "columnsFrom": [
            "skill_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_test_runs_input_id_company_skill_test_inputs_id_fk": {
          "name": "company_skill_test_runs_input_id_company_skill_test_inputs_id_fk",
          "tableFrom": "company_skill_test_runs",
          "tableTo": "company_skill_test_inputs",
          "columnsFrom": [
            "input_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_skill_test_runs_skill_version_id_company_skill_versions_id_fk": {
          "name": "company_skill_test_runs_skill_version_id_company_skill_versions_id_fk",
          "tableFrom": "company_skill_test_runs",
          "tableTo": "company_skill_versions",
          "columnsFrom": [
            "skill_version_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "company_skill_test_runs_agent_id_agents_id_fk": {
          "name": "company_skill_test_runs_agent_id_agents_id_fk",
          "tableFrom": "company_skill_test_runs",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "company_skill_test_runs_issue_id_issues_id_fk": {
          "name": "company_skill_test_runs_issue_id_issues_id_fk",
          "tableFrom": "company_skill_test_runs",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_skill_versions": {
      "name": "company_skill_versions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "company_skill_id": {
          "name": "company_skill_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "repository_snapshot_id": {
          "name": "repository_snapshot_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "repository_skill_path": {
          "name": "repository_skill_path",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "revision_number": {
          "name": "revision_number",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "label": {
          "name": "label",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "release_id": {
          "name": "release_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "release_name": {
          "name": "release_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "released_at": {
          "name": "released_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "file_inventory": {
          "name": "file_inventory",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "author_agent_id": {
          "name": "author_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "author_user_id": {
          "name": "author_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_skill_versions_skill_revision_idx": {
          "name": "company_skill_versions_skill_revision_idx",
          "columns": [
            {
              "expression": "company_skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "revision_number",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_versions_skill_release_idx": {
          "name": "company_skill_versions_skill_release_idx",
          "columns": [
            {
              "expression": "company_skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "release_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"company_skill_versions\".\"release_id\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skill_versions_company_skill_created_idx": {
          "name": "company_skill_versions_company_skill_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "company_skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_skill_versions_company_id_companies_id_fk": {
          "name": "company_skill_versions_company_id_companies_id_fk",
          "tableFrom": "company_skill_versions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_versions_company_skill_id_company_skills_id_fk": {
          "name": "company_skill_versions_company_skill_id_company_skills_id_fk",
          "tableFrom": "company_skill_versions",
          "tableTo": "company_skills",
          "columnsFrom": [
            "company_skill_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "company_skill_versions_repository_snapshot_id_company_skill_repository_snapshots_id_fk": {
          "name": "company_skill_versions_repository_snapshot_id_company_skill_repository_snapshots_id_fk",
          "tableFrom": "company_skill_versions",
          "tableTo": "company_skill_repository_snapshots",
          "columnsFrom": [
            "repository_snapshot_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "company_skill_versions_author_agent_id_agents_id_fk": {
          "name": "company_skill_versions_author_agent_id_agents_id_fk",
          "tableFrom": "company_skill_versions",
          "tableTo": "agents",
          "columnsFrom": [
            "author_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_skills": {
      "name": "company_skills",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "folder_id": {
          "name": "folder_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "slug": {
          "name": "slug",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "markdown": {
          "name": "markdown",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_type": {
          "name": "source_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'local_path'"
        },
        "source_locator": {
          "name": "source_locator",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "source_ref": {
          "name": "source_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "trust_level": {
          "name": "trust_level",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'markdown_only'"
        },
        "compatibility": {
          "name": "compatibility",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'compatible'"
        },
        "file_inventory": {
          "name": "file_inventory",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "icon_url": {
          "name": "icon_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "color": {
          "name": "color",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "tagline": {
          "name": "tagline",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "author_name": {
          "name": "author_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "homepage_url": {
          "name": "homepage_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "categories": {
          "name": "categories",
          "type": "text[]",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'"
        },
        "sharing_scope": {
          "name": "sharing_scope",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'company'"
        },
        "access_source_id": {
          "name": "access_source_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "public_share_token": {
          "name": "public_share_token",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "forked_from_skill_id": {
          "name": "forked_from_skill_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "forked_from_company_id": {
          "name": "forked_from_company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "star_count": {
          "name": "star_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "install_count": {
          "name": "install_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "fork_count": {
          "name": "fork_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "current_version_id": {
          "name": "current_version_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_skills_company_key_idx": {
          "name": "company_skills_company_key_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skills_company_name_idx": {
          "name": "company_skills_company_name_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "name",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skills_company_folder_idx": {
          "name": "company_skills_company_folder_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "folder_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skills_company_categories_idx": {
          "name": "company_skills_company_categories_idx",
          "columns": [
            {
              "expression": "categories",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "gin",
          "with": {}
        },
        "company_skills_company_sharing_scope_idx": {
          "name": "company_skills_company_sharing_scope_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "sharing_scope",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skills_company_current_version_idx": {
          "name": "company_skills_company_current_version_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "current_version_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_skills_company_forked_from_idx": {
          "name": "company_skills_company_forked_from_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "forked_from_skill_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_skills_company_id_companies_id_fk": {
          "name": "company_skills_company_id_companies_id_fk",
          "tableFrom": "company_skills",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "company_skills_folder_id_folders_id_fk": {
          "name": "company_skills_folder_id_folders_id_fk",
          "tableFrom": "company_skills",
          "tableTo": "folders",
          "columnsFrom": [
            "folder_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_skills_forked_from_skill_id_company_skills_id_fk": {
          "name": "company_skills_forked_from_skill_id_company_skills_id_fk",
          "tableFrom": "company_skills",
          "tableTo": "company_skills",
          "columnsFrom": [
            "forked_from_skill_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_skills_forked_from_company_id_companies_id_fk": {
          "name": "company_skills_forked_from_company_id_companies_id_fk",
          "tableFrom": "company_skills",
          "tableTo": "companies",
          "columnsFrom": [
            "forked_from_company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "company_skills_current_version_id_company_skill_versions_id_fk": {
          "name": "company_skills_current_version_id_company_skill_versions_id_fk",
          "tableFrom": "company_skills",
          "tableTo": "company_skill_versions",
          "columnsFrom": [
            "current_version_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_transfer_runs": {
      "name": "company_transfer_runs",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "direction": {
          "name": "direction",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "actor_key": {
          "name": "actor_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "container_ref": {
          "name": "container_ref",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "manifest_sha256": {
          "name": "manifest_sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "manifest": {
          "name": "manifest",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "chunk_count": {
          "name": "chunk_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "blob_count": {
          "name": "blob_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "completed_parts": {
          "name": "completed_parts",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "error": {
          "name": "error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "started_at": {
          "name": "started_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "finished_at": {
          "name": "finished_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_transfer_runs_company_idx": {
          "name": "company_transfer_runs_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_transfer_runs_idempotency_direction_idx": {
          "name": "company_transfer_runs_idempotency_direction_idx",
          "columns": [
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "direction",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_transfer_runs_actor_status_idx": {
          "name": "company_transfer_runs_actor_status_idx",
          "columns": [
            {
              "expression": "actor_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_transfer_runs_company_id_companies_id_fk": {
          "name": "company_transfer_runs_company_id_companies_id_fk",
          "tableFrom": "company_transfer_runs",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_user_sidebar_preferences": {
      "name": "company_user_sidebar_preferences",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "project_order": {
          "name": "project_order",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "company_user_sidebar_preferences_company_idx": {
          "name": "company_user_sidebar_preferences_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_user_sidebar_preferences_user_idx": {
          "name": "company_user_sidebar_preferences_user_idx",
          "columns": [
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "company_user_sidebar_preferences_company_user_uq": {
          "name": "company_user_sidebar_preferences_company_user_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "company_user_sidebar_preferences_company_id_companies_id_fk": {
          "name": "company_user_sidebar_preferences_company_id_companies_id_fk",
          "tableFrom": "company_user_sidebar_preferences",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.completion_contracts": {
      "name": "completion_contracts",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "revision": {
          "name": "revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "schema_version": {
          "name": "schema_version",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "policy_version": {
          "name": "policy_version",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "risk": {
          "name": "risk",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "completion_authority": {
          "name": "completion_authority",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "incomplete_criteria_policy": {
          "name": "incomplete_criteria_policy",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "contract_json": {
          "name": "contract_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "canonical_sha256": {
          "name": "canonical_sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_by_actor_type": {
          "name": "created_by_actor_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_by_actor_id": {
          "name": "created_by_actor_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "supersedes_contract_id": {
          "name": "supersedes_contract_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {
        "completion_contracts_issue_revision_uq": {
          "name": "completion_contracts_issue_revision_uq",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "revision",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "completion_contracts_issue_hash_uq": {
          "name": "completion_contracts_issue_hash_uq",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "canonical_sha256",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "completion_contracts_company_id_companies_id_fk": {
          "name": "completion_contracts_company_id_companies_id_fk",
          "tableFrom": "completion_contracts",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "completion_contracts_issue_company_fk": {
          "name": "completion_contracts_issue_company_fk",
          "tableFrom": "completion_contracts",
          "tableTo": "issues",
          "columnsFrom": [
            "company_id",
            "issue_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "completion_contracts_supersedes_owner_fk": {
          "name": "completion_contracts_supersedes_owner_fk",
          "tableFrom": "completion_contracts",
          "tableTo": "completion_contracts",
          "columnsFrom": [
            "company_id",
            "issue_id",
            "supersedes_contract_id"
          ],
          "columnsTo": [
            "company_id",
            "issue_id",
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "completion_contracts_company_issue_id_uq": {
          "name": "completion_contracts_company_issue_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "issue_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.connection_event_deliveries": {
      "name": "connection_event_deliveries",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider_delivery_id": {
          "name": "provider_delivery_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "event": {
          "name": "event",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "action": {
          "name": "action",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "installation_id": {
          "name": "installation_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "repository_id": {
          "name": "repository_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "normalized_payload": {
          "name": "normalized_payload",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'received'"
        },
        "attempts": {
          "name": "attempts",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "last_error": {
          "name": "last_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "provider_created_at": {
          "name": "provider_created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "processed_at": {
          "name": "processed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "connection_event_deliveries_company_provider_id_uq": {
          "name": "connection_event_deliveries_company_provider_id_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_delivery_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "connection_event_deliveries_company_status_idx": {
          "name": "connection_event_deliveries_company_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "connection_event_deliveries_company_id_companies_id_fk": {
          "name": "connection_event_deliveries_company_id_companies_id_fk",
          "tableFrom": "connection_event_deliveries",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.connection_intent_deliveries": {
      "name": "connection_intent_deliveries",
      "schema": "",
      "columns": {
        "interaction_id": {
          "name": "interaction_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "next_attempt_at": {
          "name": "next_attempt_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "delivered_at": {
          "name": "delivered_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "connection_intent_deliveries_pending_idx": {
          "name": "connection_intent_deliveries_pending_idx",
          "columns": [
            {
              "expression": "delivered_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "next_attempt_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "connection_intent_deliveries_interaction_id_issue_thread_interactions_id_fk": {
          "name": "connection_intent_deliveries_interaction_id_issue_thread_interactions_id_fk",
          "tableFrom": "connection_intent_deliveries",
          "tableTo": "issue_thread_interactions",
          "columnsFrom": [
            "interaction_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "connection_intent_deliveries_company_id_companies_id_fk": {
          "name": "connection_intent_deliveries_company_id_companies_id_fk",
          "tableFrom": "connection_intent_deliveries",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.cost_events": {
      "name": "cost_events",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "usage_kind": {
          "name": "usage_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'agent'"
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "project_id": {
          "name": "project_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "goal_id": {
          "name": "goal_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "heartbeat_run_id": {
          "name": "heartbeat_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "subscription_id": {
          "name": "subscription_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "billing_code": {
          "name": "billing_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "receipt_hash": {
          "name": "receipt_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "provider_request_id": {
          "name": "provider_request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "reported_cost_cents": {
          "name": "reported_cost_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": false
        },
        "pricing_provenance": {
          "name": "pricing_provenance",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "biller": {
          "name": "biller",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'unknown'"
        },
        "billing_type": {
          "name": "billing_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'unknown'"
        },
        "cost_status": {
          "name": "cost_status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'reported'"
        },
        "model": {
          "name": "model",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "input_tokens": {
          "name": "input_tokens",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "cached_input_tokens": {
          "name": "cached_input_tokens",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "output_tokens": {
          "name": "output_tokens",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "cost_cents": {
          "name": "cost_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true
        },
        "occurred_at": {
          "name": "occurred_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "cost_events_company_receipt_idx": {
          "name": "cost_events_company_receipt_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_events_provider_request_idx": {
          "name": "cost_events_provider_request_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "biller",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_request_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_events_company_project_occurred_idx": {
          "name": "cost_events_company_project_occurred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "project_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_events_unpriced_idx": {
          "name": "cost_events_unpriced_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"cost_events\".\"cost_status\" = 'unpriced' and \"cost_events\".\"billing_type\" <> 'subscription_included'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_events_data_quality_idx": {
          "name": "cost_events_data_quality_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": false,
              "nulls": "last"
            },
            {
              "expression": "id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"cost_events\".\"billing_type\" = 'unknown' or (\"cost_events\".\"cost_status\" = 'unpriced' and \"cost_events\".\"billing_type\" <> 'subscription_included')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_events_company_occurred_idx": {
          "name": "cost_events_company_occurred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_events_company_subscription_occurred_idx": {
          "name": "cost_events_company_subscription_occurred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "subscription_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_events_company_agent_occurred_idx": {
          "name": "cost_events_company_agent_occurred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_events_company_provider_occurred_idx": {
          "name": "cost_events_company_provider_occurred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_events_company_biller_occurred_idx": {
          "name": "cost_events_company_biller_occurred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "biller",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "cost_events_company_heartbeat_run_idx": {
          "name": "cost_events_company_heartbeat_run_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "heartbeat_run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "cost_events_company_id_companies_id_fk": {
          "name": "cost_events_company_id_companies_id_fk",
          "tableFrom": "cost_events",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "cost_events_agent_id_agents_id_fk": {
          "name": "cost_events_agent_id_agents_id_fk",
          "tableFrom": "cost_events",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "cost_events_issue_id_issues_id_fk": {
          "name": "cost_events_issue_id_issues_id_fk",
          "tableFrom": "cost_events",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "cost_events_project_id_projects_id_fk": {
          "name": "cost_events_project_id_projects_id_fk",
          "tableFrom": "cost_events",
          "tableTo": "projects",
          "columnsFrom": [
            "project_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "cost_events_goal_id_goals_id_fk": {
          "name": "cost_events_goal_id_goals_id_fk",
          "tableFrom": "cost_events",
          "tableTo": "goals",
          "columnsFrom": [
            "goal_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "cost_events_heartbeat_run_id_heartbeat_runs_id_fk": {
          "name": "cost_events_heartbeat_run_id_heartbeat_runs_id_fk",
          "tableFrom": "cost_events",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "heartbeat_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "cost_events_subscription_id_ai_subscriptions_id_fk": {
          "name": "cost_events_subscription_id_ai_subscriptions_id_fk",
          "tableFrom": "cost_events",
          "tableTo": "ai_subscriptions",
          "columnsFrom": [
            "subscription_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "cost_events_usage_kind_check": {
          "name": "cost_events_usage_kind_check",
          "value": "\"cost_events\".\"usage_kind\" in ('decision', 'fast_response', 'prompt_injection') or (\"cost_events\".\"usage_kind\" = 'agent' and \"cost_events\".\"agent_id\" is not null)"
        },
        "cost_events_nonnegative_amounts": {
          "name": "cost_events_nonnegative_amounts",
          "value": "\"cost_events\".\"cost_cents\" >= 0 and \"cost_events\".\"input_tokens\" >= 0 and \"cost_events\".\"cached_input_tokens\" >= 0 and \"cost_events\".\"output_tokens\" >= 0"
        }
      },
      "isRLSEnabled": false
    },
    "public.company_decision_models": {
      "name": "company_decision_models",
      "schema": "",
      "columns": {
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "enabled": {
          "name": "enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "allow_background": {
          "name": "allow_background",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "model": {
          "name": "model",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "company_decision_models_company_id_companies_id_fk": {
          "name": "company_decision_models_company_id_companies_id_fk",
          "tableFrom": "company_decision_models",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "company_decisions_configured": {
          "name": "company_decisions_configured",
          "value": "(\"company_decision_models\".\"connection_id\" is null) = (\"company_decision_models\".\"grant_id\" is null) and (not \"company_decision_models\".\"enabled\" or (\"company_decision_models\".\"connection_id\" is not null and \"company_decision_models\".\"provider\" is not null and \"company_decision_models\".\"model\" is not null))"
        }
      },
      "isRLSEnabled": false
    },
    "public.decision_invocations": {
      "name": "decision_invocations",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "feature": {
          "name": "feature",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "actor_type": {
          "name": "actor_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "actor_id": {
          "name": "actor_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "project_id": {
          "name": "project_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "identity_context_id": {
          "name": "identity_context_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "model": {
          "name": "model",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "question_types": {
          "name": "question_types",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'running'"
        },
        "error_code": {
          "name": "error_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "provider_request_id": {
          "name": "provider_request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "cost_event_id": {
          "name": "cost_event_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "started_at": {
          "name": "started_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "finished_at": {
          "name": "finished_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "duration_ms": {
          "name": "duration_ms",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "input_tokens": {
          "name": "input_tokens",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "output_tokens": {
          "name": "output_tokens",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {
        "decision_invocations_company_started_idx": {
          "name": "decision_invocations_company_started_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "started_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_invocations_pending_idx": {
          "name": "decision_invocations_pending_idx",
          "columns": [
            {
              "expression": "started_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"decision_invocations\".\"status\" = 'running'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_invocations_cost_idx": {
          "name": "decision_invocations_cost_idx",
          "columns": [
            {
              "expression": "cost_event_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decision_invocations_company_id_companies_id_fk": {
          "name": "decision_invocations_company_id_companies_id_fk",
          "tableFrom": "decision_invocations",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "decision_invocations_cost_event_id_cost_events_id_fk": {
          "name": "decision_invocations_cost_event_id_cost_events_id_fk",
          "tableFrom": "decision_invocations",
          "tableTo": "cost_events",
          "columnsFrom": [
            "cost_event_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "decision_invocations_status_check": {
          "name": "decision_invocations_status_check",
          "value": "\"decision_invocations\".\"status\" in ('running', 'succeeded', 'failed', 'unknown')"
        }
      },
      "isRLSEnabled": false
    },
    "public.decision_archive_notification_outbox": {
      "name": "decision_archive_notification_outbox",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_kind": {
          "name": "source_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_id": {
          "name": "source_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "archive_version": {
          "name": "archive_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "origin_agent_id": {
          "name": "origin_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "origin_issue_id": {
          "name": "origin_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "attempt_count": {
          "name": "attempt_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "last_attempt_at": {
          "name": "last_attempt_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "delivered_at": {
          "name": "delivered_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "decision_archive_notification_outbox_uq": {
          "name": "decision_archive_notification_outbox_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "archive_version",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "origin_agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_archive_notification_outbox_pending_idx": {
          "name": "decision_archive_notification_outbox_pending_idx",
          "columns": [
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decision_archive_notification_outbox_company_id_companies_id_fk": {
          "name": "decision_archive_notification_outbox_company_id_companies_id_fk",
          "tableFrom": "decision_archive_notification_outbox",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "decision_archive_notification_outbox_origin_agent_id_agents_id_fk": {
          "name": "decision_archive_notification_outbox_origin_agent_id_agents_id_fk",
          "tableFrom": "decision_archive_notification_outbox",
          "tableTo": "agents",
          "columnsFrom": [
            "origin_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "decision_archive_notification_outbox_status_check": {
          "name": "decision_archive_notification_outbox_status_check",
          "value": "\"decision_archive_notification_outbox\".\"status\" IN ('pending', 'delivering', 'delivered')"
        }
      },
      "isRLSEnabled": false
    },
    "public.decision_queue_items": {
      "name": "decision_queue_items",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "queue_id": {
          "name": "queue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_kind": {
          "name": "source_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_id": {
          "name": "source_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "added_by_type": {
          "name": "added_by_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "added_by_agent_id": {
          "name": "added_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "added_by_user_id": {
          "name": "added_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "added_by_run_id": {
          "name": "added_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "added_by_agent_api_key_id": {
          "name": "added_by_agent_api_key_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "decision_queue_items_queue_source_uq": {
          "name": "decision_queue_items_queue_source_uq",
          "columns": [
            {
              "expression": "queue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_queue_items_company_source_idx": {
          "name": "decision_queue_items_company_source_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decision_queue_items_company_id_companies_id_fk": {
          "name": "decision_queue_items_company_id_companies_id_fk",
          "tableFrom": "decision_queue_items",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "decision_queue_items_added_by_agent_id_agents_id_fk": {
          "name": "decision_queue_items_added_by_agent_id_agents_id_fk",
          "tableFrom": "decision_queue_items",
          "tableTo": "agents",
          "columnsFrom": [
            "added_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_queue_items_added_by_run_id_heartbeat_runs_id_fk": {
          "name": "decision_queue_items_added_by_run_id_heartbeat_runs_id_fk",
          "tableFrom": "decision_queue_items",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "added_by_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_queue_items_added_by_agent_api_key_id_agent_api_keys_id_fk": {
          "name": "decision_queue_items_added_by_agent_api_key_id_agent_api_keys_id_fk",
          "tableFrom": "decision_queue_items",
          "tableTo": "agent_api_keys",
          "columnsFrom": [
            "added_by_agent_api_key_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_queue_items_queue_company_fk": {
          "name": "decision_queue_items_queue_company_fk",
          "tableFrom": "decision_queue_items",
          "tableTo": "decision_queues",
          "columnsFrom": [
            "queue_id",
            "company_id"
          ],
          "columnsTo": [
            "id",
            "company_id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "decision_queue_items_actor_check": {
          "name": "decision_queue_items_actor_check",
          "value": "(\n        (\"decision_queue_items\".\"added_by_type\" = 'agent' AND \"decision_queue_items\".\"added_by_agent_id\" IS NOT NULL AND \"decision_queue_items\".\"added_by_user_id\" IS NULL)\n        OR (\"decision_queue_items\".\"added_by_type\" = 'user' AND \"decision_queue_items\".\"added_by_agent_id\" IS NULL AND \"decision_queue_items\".\"added_by_user_id\" IS NOT NULL)\n        OR (\"decision_queue_items\".\"added_by_type\" = 'system' AND \"decision_queue_items\".\"added_by_agent_id\" IS NULL AND \"decision_queue_items\".\"added_by_user_id\" IS NULL)\n      )"
        }
      },
      "isRLSEnabled": false
    },
    "public.decision_queues": {
      "name": "decision_queues",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_type": {
          "name": "created_by_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_run_id": {
          "name": "created_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_agent_api_key_id": {
          "name": "created_by_agent_api_key_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "retention_days": {
          "name": "retention_days",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "seed_rules": {
          "name": "seed_rules",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "seed_rules_enabled": {
          "name": "seed_rules_enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "decision_queues_company_key_uq": {
          "name": "decision_queues_company_key_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_queues_company_updated_idx": {
          "name": "decision_queues_company_updated_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "updated_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decision_queues_company_id_companies_id_fk": {
          "name": "decision_queues_company_id_companies_id_fk",
          "tableFrom": "decision_queues",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "decision_queues_created_by_agent_id_agents_id_fk": {
          "name": "decision_queues_created_by_agent_id_agents_id_fk",
          "tableFrom": "decision_queues",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_queues_created_by_run_id_heartbeat_runs_id_fk": {
          "name": "decision_queues_created_by_run_id_heartbeat_runs_id_fk",
          "tableFrom": "decision_queues",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "created_by_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_queues_created_by_agent_api_key_id_agent_api_keys_id_fk": {
          "name": "decision_queues_created_by_agent_api_key_id_agent_api_keys_id_fk",
          "tableFrom": "decision_queues",
          "tableTo": "agent_api_keys",
          "columnsFrom": [
            "created_by_agent_api_key_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "decision_queues_id_company_uq": {
          "name": "decision_queues_id_company_uq",
          "nullsNotDistinct": false,
          "columns": [
            "id",
            "company_id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "decision_queues_creator_check": {
          "name": "decision_queues_creator_check",
          "value": "(\n        (\"decision_queues\".\"created_by_type\" = 'agent' AND \"decision_queues\".\"created_by_agent_id\" IS NOT NULL AND \"decision_queues\".\"created_by_user_id\" IS NULL)\n        OR (\"decision_queues\".\"created_by_type\" = 'user' AND \"decision_queues\".\"created_by_agent_id\" IS NULL AND \"decision_queues\".\"created_by_user_id\" IS NOT NULL)\n        OR (\"decision_queues\".\"created_by_type\" = 'system' AND \"decision_queues\".\"created_by_agent_id\" IS NULL AND \"decision_queues\".\"created_by_user_id\" IS NULL)\n      )"
        },
        "decision_queues_retention_days_check": {
          "name": "decision_queues_retention_days_check",
          "value": "\"decision_queues\".\"retention_days\" IS NULL OR (\"decision_queues\".\"retention_days\" >= 1 AND \"decision_queues\".\"retention_days\" <= 3650)"
        }
      },
      "isRLSEnabled": false
    },
    "public.decision_retention": {
      "name": "decision_retention",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_kind": {
          "name": "source_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_id": {
          "name": "source_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_activity_at": {
          "name": "source_activity_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "keep": {
          "name": "keep",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "archived_at": {
          "name": "archived_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "archived_reason": {
          "name": "archived_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "archived_by_type": {
          "name": "archived_by_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "archived_by_agent_id": {
          "name": "archived_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "archived_by_user_id": {
          "name": "archived_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "archived_by_run_id": {
          "name": "archived_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "version": {
          "name": "version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "archive_version": {
          "name": "archive_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "decision_retention_company_source_uq": {
          "name": "decision_retention_company_source_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_retention_company_archived_idx": {
          "name": "decision_retention_company_archived_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "archived_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decision_retention_company_id_companies_id_fk": {
          "name": "decision_retention_company_id_companies_id_fk",
          "tableFrom": "decision_retention",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "decision_retention_archived_by_agent_id_agents_id_fk": {
          "name": "decision_retention_archived_by_agent_id_agents_id_fk",
          "tableFrom": "decision_retention",
          "tableTo": "agents",
          "columnsFrom": [
            "archived_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_retention_archived_by_run_id_heartbeat_runs_id_fk": {
          "name": "decision_retention_archived_by_run_id_heartbeat_runs_id_fk",
          "tableFrom": "decision_retention",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "archived_by_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "decision_retention_archive_actor_check": {
          "name": "decision_retention_archive_actor_check",
          "value": "(\n        (\"decision_retention\".\"archived_at\" IS NULL AND \"decision_retention\".\"archived_by_type\" IS NULL AND \"decision_retention\".\"archived_by_agent_id\" IS NULL AND \"decision_retention\".\"archived_by_user_id\" IS NULL)\n        OR (\"decision_retention\".\"archived_at\" IS NOT NULL AND \"decision_retention\".\"archived_by_type\" = 'system' AND \"decision_retention\".\"archived_by_agent_id\" IS NULL AND \"decision_retention\".\"archived_by_user_id\" IS NULL)\n        OR (\"decision_retention\".\"archived_at\" IS NOT NULL AND \"decision_retention\".\"archived_by_type\" = 'agent' AND \"decision_retention\".\"archived_by_agent_id\" IS NOT NULL AND \"decision_retention\".\"archived_by_user_id\" IS NULL)\n        OR (\"decision_retention\".\"archived_at\" IS NOT NULL AND \"decision_retention\".\"archived_by_type\" = 'user' AND \"decision_retention\".\"archived_by_agent_id\" IS NULL AND \"decision_retention\".\"archived_by_user_id\" IS NOT NULL)\n      )"
        }
      },
      "isRLSEnabled": false
    },
    "public.decision_triage": {
      "name": "decision_triage",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_kind": {
          "name": "source_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_id": {
          "name": "source_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "decide_by": {
          "name": "decide_by",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "decide_by_date": {
          "name": "decide_by_date",
          "type": "date",
          "primaryKey": false,
          "notNull": false
        },
        "snoozed_until": {
          "name": "snoozed_until",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "set_by_type": {
          "name": "set_by_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "set_by_agent_id": {
          "name": "set_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "set_by_user_id": {
          "name": "set_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "set_by_run_id": {
          "name": "set_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "set_by_agent_api_key_id": {
          "name": "set_by_agent_api_key_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "version": {
          "name": "version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "decision_triage_company_source_uq": {
          "name": "decision_triage_company_source_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_triage_company_decide_by_idx": {
          "name": "decision_triage_company_decide_by_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "decide_by",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decision_triage_company_id_companies_id_fk": {
          "name": "decision_triage_company_id_companies_id_fk",
          "tableFrom": "decision_triage",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "decision_triage_set_by_agent_id_agents_id_fk": {
          "name": "decision_triage_set_by_agent_id_agents_id_fk",
          "tableFrom": "decision_triage",
          "tableTo": "agents",
          "columnsFrom": [
            "set_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_triage_set_by_run_id_heartbeat_runs_id_fk": {
          "name": "decision_triage_set_by_run_id_heartbeat_runs_id_fk",
          "tableFrom": "decision_triage",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "set_by_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_triage_set_by_agent_api_key_id_agent_api_keys_id_fk": {
          "name": "decision_triage_set_by_agent_api_key_id_agent_api_keys_id_fk",
          "tableFrom": "decision_triage",
          "tableTo": "agent_api_keys",
          "columnsFrom": [
            "set_by_agent_api_key_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "decision_triage_actor_check": {
          "name": "decision_triage_actor_check",
          "value": "(\n        (\"decision_triage\".\"set_by_type\" = 'agent' AND \"decision_triage\".\"set_by_agent_id\" IS NOT NULL AND \"decision_triage\".\"set_by_user_id\" IS NULL)\n        OR (\"decision_triage\".\"set_by_type\" = 'user' AND \"decision_triage\".\"set_by_agent_id\" IS NULL AND \"decision_triage\".\"set_by_user_id\" IS NOT NULL)\n      )"
        },
        "decision_triage_decide_by_check": {
          "name": "decision_triage_decide_by_check",
          "value": "(\n        (\"decision_triage\".\"decide_by\" IS NULL AND \"decision_triage\".\"decide_by_date\" IS NULL)\n        OR (\"decision_triage\".\"decide_by\" IN ('today', 'this_week', 'whenever') AND \"decision_triage\".\"decide_by_date\" IS NULL)\n        OR (\"decision_triage\".\"decide_by\" = 'date' AND \"decision_triage\".\"decide_by_date\" IS NOT NULL)\n      )"
        }
      },
      "isRLSEnabled": false
    },
    "public.decision_triage_events": {
      "name": "decision_triage_events",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "queue_id": {
          "name": "queue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "source_kind": {
          "name": "source_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "source_id": {
          "name": "source_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "action": {
          "name": "action",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "actor_type": {
          "name": "actor_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "actor_agent_id": {
          "name": "actor_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "actor_user_id": {
          "name": "actor_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "actor_run_id": {
          "name": "actor_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "agent_api_key_id": {
          "name": "agent_api_key_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "details": {
          "name": "details",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "decision_triage_events_company_source_created_idx": {
          "name": "decision_triage_events_company_source_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_triage_events_queue_created_idx": {
          "name": "decision_triage_events_queue_created_idx",
          "columns": [
            {
              "expression": "queue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decision_triage_events_company_id_companies_id_fk": {
          "name": "decision_triage_events_company_id_companies_id_fk",
          "tableFrom": "decision_triage_events",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "decision_triage_events_queue_id_decision_queues_id_fk": {
          "name": "decision_triage_events_queue_id_decision_queues_id_fk",
          "tableFrom": "decision_triage_events",
          "tableTo": "decision_queues",
          "columnsFrom": [
            "queue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_triage_events_actor_agent_id_agents_id_fk": {
          "name": "decision_triage_events_actor_agent_id_agents_id_fk",
          "tableFrom": "decision_triage_events",
          "tableTo": "agents",
          "columnsFrom": [
            "actor_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_triage_events_actor_run_id_heartbeat_runs_id_fk": {
          "name": "decision_triage_events_actor_run_id_heartbeat_runs_id_fk",
          "tableFrom": "decision_triage_events",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "actor_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_triage_events_agent_api_key_id_agent_api_keys_id_fk": {
          "name": "decision_triage_events_agent_api_key_id_agent_api_keys_id_fk",
          "tableFrom": "decision_triage_events",
          "tableTo": "agent_api_keys",
          "columnsFrom": [
            "agent_api_key_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "decision_triage_events_actor_check": {
          "name": "decision_triage_events_actor_check",
          "value": "(\n        (\"decision_triage_events\".\"actor_type\" = 'agent' AND \"decision_triage_events\".\"actor_agent_id\" IS NOT NULL AND \"decision_triage_events\".\"actor_user_id\" IS NULL)\n        OR (\"decision_triage_events\".\"actor_type\" = 'user' AND \"decision_triage_events\".\"actor_agent_id\" IS NULL AND \"decision_triage_events\".\"actor_user_id\" IS NOT NULL)\n        OR (\"decision_triage_events\".\"actor_type\" = 'system' AND \"decision_triage_events\".\"actor_agent_id\" IS NULL AND \"decision_triage_events\".\"actor_user_id\" IS NULL)\n      )"
        }
      },
      "isRLSEnabled": false
    },
    "public.decision_training_examples": {
      "name": "decision_training_examples",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_kind": {
          "name": "source_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_id": {
          "name": "source_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "cutoff_at": {
          "name": "cutoff_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "notes": {
          "name": "notes",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "''"
        },
        "notes_history": {
          "name": "notes_history",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "decision_outcome": {
          "name": "decision_outcome",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "retention_policy": {
          "name": "retention_policy",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'scrub_deleted_comments_v1'"
        },
        "snapshot": {
          "name": "snapshot",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "decision_training_examples_company_created_at_idx": {
          "name": "decision_training_examples_company_created_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_training_examples_issue_idx": {
          "name": "decision_training_examples_issue_idx",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_training_examples_source_author_uq": {
          "name": "decision_training_examples_source_author_uq",
          "columns": [
            {
              "expression": "source_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_by_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decision_training_examples_company_id_companies_id_fk": {
          "name": "decision_training_examples_company_id_companies_id_fk",
          "tableFrom": "decision_training_examples",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "decision_training_examples_issue_id_issues_id_fk": {
          "name": "decision_training_examples_issue_id_issues_id_fk",
          "tableFrom": "decision_training_examples",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.decision_bundles": {
      "name": "decision_bundles",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "summary": {
          "name": "summary",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "origin_agent_id": {
          "name": "origin_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "origin_issue_id": {
          "name": "origin_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "origin_run_id": {
          "name": "origin_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "decision_bundles_company_created_at_idx": {
          "name": "decision_bundles_company_created_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decision_bundles_company_id_companies_id_fk": {
          "name": "decision_bundles_company_id_companies_id_fk",
          "tableFrom": "decision_bundles",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_bundles_origin_agent_id_agents_id_fk": {
          "name": "decision_bundles_origin_agent_id_agents_id_fk",
          "tableFrom": "decision_bundles",
          "tableTo": "agents",
          "columnsFrom": [
            "origin_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_bundles_origin_issue_id_issues_id_fk": {
          "name": "decision_bundles_origin_issue_id_issues_id_fk",
          "tableFrom": "decision_bundles",
          "tableTo": "issues",
          "columnsFrom": [
            "origin_issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_bundles_origin_run_id_heartbeat_runs_id_fk": {
          "name": "decision_bundles_origin_run_id_heartbeat_runs_id_fk",
          "tableFrom": "decision_bundles",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "origin_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.decision_effect_executions": {
      "name": "decision_effect_executions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "decision_id": {
          "name": "decision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "effect_index": {
          "name": "effect_index",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "effect_type": {
          "name": "effect_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "target_issue_id": {
          "name": "target_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'claimed'"
        },
        "result": {
          "name": "result",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "error": {
          "name": "error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "activity_log_id": {
          "name": "activity_log_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "executed_at": {
          "name": "executed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {
        "decision_effect_executions_decision_effect_uq": {
          "name": "decision_effect_executions_decision_effect_uq",
          "columns": [
            {
              "expression": "decision_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "effect_index",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_effect_executions_target_issue_idx": {
          "name": "decision_effect_executions_target_issue_idx",
          "columns": [
            {
              "expression": "target_issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decision_effect_executions_decision_id_decisions_id_fk": {
          "name": "decision_effect_executions_decision_id_decisions_id_fk",
          "tableFrom": "decision_effect_executions",
          "tableTo": "decisions",
          "columnsFrom": [
            "decision_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "decision_effect_executions_target_issue_id_issues_id_fk": {
          "name": "decision_effect_executions_target_issue_id_issues_id_fk",
          "tableFrom": "decision_effect_executions",
          "tableTo": "issues",
          "columnsFrom": [
            "target_issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decision_effect_executions_activity_log_id_activity_log_id_fk": {
          "name": "decision_effect_executions_activity_log_id_activity_log_id_fk",
          "tableFrom": "decision_effect_executions",
          "tableTo": "activity_log",
          "columnsFrom": [
            "activity_log_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.decision_target_issues": {
      "name": "decision_target_issues",
      "schema": "",
      "columns": {
        "decision_id": {
          "name": "decision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        }
      },
      "indexes": {
        "decision_target_issues_decision_idx": {
          "name": "decision_target_issues_decision_idx",
          "columns": [
            {
              "expression": "decision_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decision_target_issues_issue_idx": {
          "name": "decision_target_issues_issue_idx",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decision_target_issues_decision_id_decisions_id_fk": {
          "name": "decision_target_issues_decision_id_decisions_id_fk",
          "tableFrom": "decision_target_issues",
          "tableTo": "decisions",
          "columnsFrom": [
            "decision_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "decision_target_issues_issue_id_issues_id_fk": {
          "name": "decision_target_issues_issue_id_issues_id_fk",
          "tableFrom": "decision_target_issues",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "decision_target_issues_company_id_companies_id_fk": {
          "name": "decision_target_issues_company_id_companies_id_fk",
          "tableFrom": "decision_target_issues",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {
        "decision_target_issues_decision_id_issue_id_pk": {
          "name": "decision_target_issues_decision_id_issue_id_pk",
          "columns": [
            "decision_id",
            "issue_id"
          ]
        }
      },
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.decisions": {
      "name": "decisions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "bundle_id": {
          "name": "bundle_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "origin_agent_id": {
          "name": "origin_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "origin_issue_id": {
          "name": "origin_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "origin_run_id": {
          "name": "origin_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "rule_key": {
          "name": "rule_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "body": {
          "name": "body",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "options": {
          "name": "options",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "inputs": {
          "name": "inputs",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'open'"
        },
        "execution_status": {
          "name": "execution_status",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "chosen_option_id": {
          "name": "chosen_option_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "input_values": {
          "name": "input_values",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "decided_by_user_id": {
          "name": "decided_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "decided_at": {
          "name": "decided_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "signed_spec": {
          "name": "signed_spec",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "target_snapshots": {
          "name": "target_snapshots",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "continuation_policy": {
          "name": "continuation_policy",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'none'"
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "decisions_company_status_expires_at_idx": {
          "name": "decisions_company_status_expires_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decisions_bundle_idx": {
          "name": "decisions_bundle_idx",
          "columns": [
            {
              "expression": "bundle_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decisions_origin_issue_idx": {
          "name": "decisions_origin_issue_idx",
          "columns": [
            {
              "expression": "origin_issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "decisions_company_idempotency_uq": {
          "name": "decisions_company_idempotency_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"decisions\".\"idempotency_key\" IS NOT NULL",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "decisions_company_id_companies_id_fk": {
          "name": "decisions_company_id_companies_id_fk",
          "tableFrom": "decisions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decisions_bundle_id_decision_bundles_id_fk": {
          "name": "decisions_bundle_id_decision_bundles_id_fk",
          "tableFrom": "decisions",
          "tableTo": "decision_bundles",
          "columnsFrom": [
            "bundle_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "decisions_origin_agent_id_agents_id_fk": {
          "name": "decisions_origin_agent_id_agents_id_fk",
          "tableFrom": "decisions",
          "tableTo": "agents",
          "columnsFrom": [
            "origin_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decisions_origin_issue_id_issues_id_fk": {
          "name": "decisions_origin_issue_id_issues_id_fk",
          "tableFrom": "decisions",
          "tableTo": "issues",
          "columnsFrom": [
            "origin_issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "decisions_origin_run_id_heartbeat_runs_id_fk": {
          "name": "decisions_origin_run_id_heartbeat_runs_id_fk",
          "tableFrom": "decisions",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "origin_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.document_annotation_anchor_snapshots": {
      "name": "document_annotation_anchor_snapshots",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "thread_id": {
          "name": "thread_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "document_id": {
          "name": "document_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "from_revision_id": {
          "name": "from_revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "from_revision_number": {
          "name": "from_revision_number",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "to_revision_id": {
          "name": "to_revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "to_revision_number": {
          "name": "to_revision_number",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "previous_anchor": {
          "name": "previous_anchor",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "next_anchor": {
          "name": "next_anchor",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "anchor_state": {
          "name": "anchor_state",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "anchor_confidence": {
          "name": "anchor_confidence",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "failure_reason": {
          "name": "failure_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "document_annotation_anchor_snapshots_company_thread_created_at_idx": {
          "name": "document_annotation_anchor_snapshots_company_thread_created_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "thread_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_anchor_snapshots_company_document_revision_idx": {
          "name": "document_annotation_anchor_snapshots_company_document_revision_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "document_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "to_revision_number",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "document_annotation_anchor_snapshots_company_id_companies_id_fk": {
          "name": "document_annotation_anchor_snapshots_company_id_companies_id_fk",
          "tableFrom": "document_annotation_anchor_snapshots",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "document_annotation_anchor_snapshots_thread_id_document_annotation_threads_id_fk": {
          "name": "document_annotation_anchor_snapshots_thread_id_document_annotation_threads_id_fk",
          "tableFrom": "document_annotation_anchor_snapshots",
          "tableTo": "document_annotation_threads",
          "columnsFrom": [
            "thread_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_annotation_anchor_snapshots_document_id_documents_id_fk": {
          "name": "document_annotation_anchor_snapshots_document_id_documents_id_fk",
          "tableFrom": "document_annotation_anchor_snapshots",
          "tableTo": "documents",
          "columnsFrom": [
            "document_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_annotation_anchor_snapshots_from_revision_id_document_revisions_id_fk": {
          "name": "document_annotation_anchor_snapshots_from_revision_id_document_revisions_id_fk",
          "tableFrom": "document_annotation_anchor_snapshots",
          "tableTo": "document_revisions",
          "columnsFrom": [
            "from_revision_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "document_annotation_anchor_snapshots_to_revision_id_document_revisions_id_fk": {
          "name": "document_annotation_anchor_snapshots_to_revision_id_document_revisions_id_fk",
          "tableFrom": "document_annotation_anchor_snapshots",
          "tableTo": "document_revisions",
          "columnsFrom": [
            "to_revision_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.document_annotation_comments": {
      "name": "document_annotation_comments",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "thread_id": {
          "name": "thread_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "routine_id": {
          "name": "routine_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "case_id": {
          "name": "case_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "document_id": {
          "name": "document_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "body": {
          "name": "body",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "author_type": {
          "name": "author_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "author_agent_id": {
          "name": "author_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "author_user_id": {
          "name": "author_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_run_id": {
          "name": "created_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "issue_comment_id": {
          "name": "issue_comment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "source_trust": {
          "name": "source_trust",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "document_annotation_comments_company_thread_created_at_idx": {
          "name": "document_annotation_comments_company_thread_created_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "thread_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_comments_company_issue_created_at_idx": {
          "name": "document_annotation_comments_company_issue_created_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_comments_company_routine_created_at_idx": {
          "name": "document_annotation_comments_company_routine_created_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "routine_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_comments_company_case_created_at_idx": {
          "name": "document_annotation_comments_company_case_created_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_comments_company_document_created_at_idx": {
          "name": "document_annotation_comments_company_document_created_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "document_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_comments_issue_comment_idx": {
          "name": "document_annotation_comments_issue_comment_idx",
          "columns": [
            {
              "expression": "issue_comment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_comments_body_search_idx": {
          "name": "document_annotation_comments_body_search_idx",
          "columns": [
            {
              "expression": "body",
              "isExpression": false,
              "asc": true,
              "nulls": "last",
              "opclass": "gin_trgm_ops"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "gin",
          "with": {}
        }
      },
      "foreignKeys": {
        "document_annotation_comments_company_id_companies_id_fk": {
          "name": "document_annotation_comments_company_id_companies_id_fk",
          "tableFrom": "document_annotation_comments",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "document_annotation_comments_thread_id_document_annotation_threads_id_fk": {
          "name": "document_annotation_comments_thread_id_document_annotation_threads_id_fk",
          "tableFrom": "document_annotation_comments",
          "tableTo": "document_annotation_threads",
          "columnsFrom": [
            "thread_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_annotation_comments_issue_id_issues_id_fk": {
          "name": "document_annotation_comments_issue_id_issues_id_fk",
          "tableFrom": "document_annotation_comments",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_annotation_comments_routine_id_routines_id_fk": {
          "name": "document_annotation_comments_routine_id_routines_id_fk",
          "tableFrom": "document_annotation_comments",
          "tableTo": "routines",
          "columnsFrom": [
            "routine_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_annotation_comments_case_id_cases_id_fk": {
          "name": "document_annotation_comments_case_id_cases_id_fk",
          "tableFrom": "document_annotation_comments",
          "tableTo": "cases",
          "columnsFrom": [
            "case_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_annotation_comments_document_id_documents_id_fk": {
          "name": "document_annotation_comments_document_id_documents_id_fk",
          "tableFrom": "document_annotation_comments",
          "tableTo": "documents",
          "columnsFrom": [
            "document_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_annotation_comments_author_agent_id_agents_id_fk": {
          "name": "document_annotation_comments_author_agent_id_agents_id_fk",
          "tableFrom": "document_annotation_comments",
          "tableTo": "agents",
          "columnsFrom": [
            "author_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "document_annotation_comments_created_by_run_id_heartbeat_runs_id_fk": {
          "name": "document_annotation_comments_created_by_run_id_heartbeat_runs_id_fk",
          "tableFrom": "document_annotation_comments",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "created_by_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "document_annotation_comments_issue_comment_id_issue_comments_id_fk": {
          "name": "document_annotation_comments_issue_comment_id_issue_comments_id_fk",
          "tableFrom": "document_annotation_comments",
          "tableTo": "issue_comments",
          "columnsFrom": [
            "issue_comment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "document_annotation_comments_exactly_one_owner_chk": {
          "name": "document_annotation_comments_exactly_one_owner_chk",
          "value": "num_nonnulls(\"document_annotation_comments\".\"issue_id\", \"document_annotation_comments\".\"routine_id\", \"document_annotation_comments\".\"case_id\") = 1"
        }
      },
      "isRLSEnabled": false
    },
    "public.document_annotation_threads": {
      "name": "document_annotation_threads",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "routine_id": {
          "name": "routine_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "case_id": {
          "name": "case_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "document_id": {
          "name": "document_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "document_key": {
          "name": "document_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'open'"
        },
        "anchor_state": {
          "name": "anchor_state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "original_revision_id": {
          "name": "original_revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "original_revision_number": {
          "name": "original_revision_number",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "current_revision_id": {
          "name": "current_revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "current_revision_number": {
          "name": "current_revision_number",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "selected_text": {
          "name": "selected_text",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "prefix_text": {
          "name": "prefix_text",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "''"
        },
        "suffix_text": {
          "name": "suffix_text",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "''"
        },
        "normalized_start": {
          "name": "normalized_start",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "normalized_end": {
          "name": "normalized_end",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "markdown_start": {
          "name": "markdown_start",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "markdown_end": {
          "name": "markdown_end",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "anchor_confidence": {
          "name": "anchor_confidence",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'exact'"
        },
        "anchor_selector": {
          "name": "anchor_selector",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "resolved_by_agent_id": {
          "name": "resolved_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "resolved_by_user_id": {
          "name": "resolved_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "resolved_at": {
          "name": "resolved_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "document_annotation_threads_company_document_status_idx": {
          "name": "document_annotation_threads_company_document_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "document_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_threads_company_issue_status_idx": {
          "name": "document_annotation_threads_company_issue_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_threads_company_routine_status_idx": {
          "name": "document_annotation_threads_company_routine_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "routine_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_threads_company_case_status_idx": {
          "name": "document_annotation_threads_company_case_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "case_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_threads_company_current_revision_open_idx": {
          "name": "document_annotation_threads_company_current_revision_open_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "document_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "current_revision_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_annotation_threads_company_anchor_state_idx": {
          "name": "document_annotation_threads_company_anchor_state_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "anchor_state",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "document_annotation_threads_company_id_companies_id_fk": {
          "name": "document_annotation_threads_company_id_companies_id_fk",
          "tableFrom": "document_annotation_threads",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "document_annotation_threads_issue_id_issues_id_fk": {
          "name": "document_annotation_threads_issue_id_issues_id_fk",
          "tableFrom": "document_annotation_threads",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_annotation_threads_routine_id_routines_id_fk": {
          "name": "document_annotation_threads_routine_id_routines_id_fk",
          "tableFrom": "document_annotation_threads",
          "tableTo": "routines",
          "columnsFrom": [
            "routine_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_annotation_threads_case_id_cases_id_fk": {
          "name": "document_annotation_threads_case_id_cases_id_fk",
          "tableFrom": "document_annotation_threads",
          "tableTo": "cases",
          "columnsFrom": [
            "case_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_annotation_threads_document_id_documents_id_fk": {
          "name": "document_annotation_threads_document_id_documents_id_fk",
          "tableFrom": "document_annotation_threads",
          "tableTo": "documents",
          "columnsFrom": [
            "document_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_annotation_threads_original_revision_id_document_revisions_id_fk": {
          "name": "document_annotation_threads_original_revision_id_document_revisions_id_fk",
          "tableFrom": "document_annotation_threads",
          "tableTo": "document_revisions",
          "columnsFrom": [
            "original_revision_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "document_annotation_threads_current_revision_id_document_revisions_id_fk": {
          "name": "document_annotation_threads_current_revision_id_document_revisions_id_fk",
          "tableFrom": "document_annotation_threads",
          "tableTo": "document_revisions",
          "columnsFrom": [
            "current_revision_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "document_annotation_threads_created_by_agent_id_agents_id_fk": {
          "name": "document_annotation_threads_created_by_agent_id_agents_id_fk",
          "tableFrom": "document_annotation_threads",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "document_annotation_threads_resolved_by_agent_id_agents_id_fk": {
          "name": "document_annotation_threads_resolved_by_agent_id_agents_id_fk",
          "tableFrom": "document_annotation_threads",
          "tableTo": "agents",
          "columnsFrom": [
            "resolved_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "document_annotation_threads_exactly_one_owner_chk": {
          "name": "document_annotation_threads_exactly_one_owner_chk",
          "value": "num_nonnulls(\"document_annotation_threads\".\"issue_id\", \"document_annotation_threads\".\"routine_id\", \"document_annotation_threads\".\"case_id\") = 1"
        }
      },
      "isRLSEnabled": false
    },
    "public.document_memberships": {
      "name": "document_memberships",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "document_id": {
          "name": "document_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "starred_at": {
          "name": "starred_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "document_memberships_company_user_starred_idx": {
          "name": "document_memberships_company_user_starred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "starred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_memberships_company_user_document_uq": {
          "name": "document_memberships_company_user_document_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "document_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "document_memberships_company_id_companies_id_fk": {
          "name": "document_memberships_company_id_companies_id_fk",
          "tableFrom": "document_memberships",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_memberships_document_id_documents_id_fk": {
          "name": "document_memberships_document_id_documents_id_fk",
          "tableFrom": "document_memberships",
          "tableTo": "documents",
          "columnsFrom": [
            "document_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.document_revisions": {
      "name": "document_revisions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "document_id": {
          "name": "document_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "revision_number": {
          "name": "revision_number",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "format": {
          "name": "format",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'markdown'"
        },
        "body": {
          "name": "body",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "change_summary": {
          "name": "change_summary",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_run_id": {
          "name": "created_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "document_revisions_document_revision_uq": {
          "name": "document_revisions_document_revision_uq",
          "columns": [
            {
              "expression": "document_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "revision_number",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "document_revisions_company_document_created_idx": {
          "name": "document_revisions_company_document_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "document_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "document_revisions_company_id_companies_id_fk": {
          "name": "document_revisions_company_id_companies_id_fk",
          "tableFrom": "document_revisions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_revisions_document_id_documents_id_fk": {
          "name": "document_revisions_document_id_documents_id_fk",
          "tableFrom": "document_revisions",
          "tableTo": "documents",
          "columnsFrom": [
            "document_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "document_revisions_created_by_agent_id_agents_id_fk": {
          "name": "document_revisions_created_by_agent_id_agents_id_fk",
          "tableFrom": "document_revisions",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "document_revisions_created_by_run_id_heartbeat_runs_id_fk": {
          "name": "document_revisions_created_by_run_id_heartbeat_runs_id_fk",
          "tableFrom": "document_revisions",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "created_by_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.documents": {
      "name": "documents",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "format": {
          "name": "format",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'markdown'"
        },
        "latest_body": {
          "name": "latest_body",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "latest_revision_id": {
          "name": "latest_revision_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "latest_revision_number": {
          "name": "latest_revision_number",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "updated_by_agent_id": {
          "name": "updated_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "updated_by_user_id": {
          "name": "updated_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "locked_at": {
          "name": "locked_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "locked_by_agent_id": {
          "name": "locked_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "locked_by_user_id": {
          "name": "locked_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "source_trust": {
          "name": "source_trust",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "documents_company_updated_idx": {
          "name": "documents_company_updated_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "updated_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "documents_company_created_idx": {
          "name": "documents_company_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "documents_title_search_idx": {
          "name": "documents_title_search_idx",
          "columns": [
            {
              "expression": "title",
              "isExpression": false,
              "asc": true,
              "nulls": "last",
              "opclass": "gin_trgm_ops"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "gin",
          "with": {}
        },
        "documents_latest_body_search_idx": {
          "name": "documents_latest_body_search_idx",
          "columns": [
            {
              "expression": "latest_body",
              "isExpression": false,
              "asc": true,
              "nulls": "last",
              "opclass": "gin_trgm_ops"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "gin",
          "with": {}
        }
      },
      "foreignKeys": {
        "documents_company_id_companies_id_fk": {
          "name": "documents_company_id_companies_id_fk",
          "tableFrom": "documents",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "documents_created_by_agent_id_agents_id_fk": {
          "name": "documents_created_by_agent_id_agents_id_fk",
          "tableFrom": "documents",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "documents_updated_by_agent_id_agents_id_fk": {
          "name": "documents_updated_by_agent_id_agents_id_fk",
          "tableFrom": "documents",
          "tableTo": "agents",
          "columnsFrom": [
            "updated_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "documents_locked_by_agent_id_agents_id_fk": {
          "name": "documents_locked_by_agent_id_agents_id_fk",
          "tableFrom": "documents",
          "tableTo": "agents",
          "columnsFrom": [
            "locked_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.dot_agent_bindings": {
      "name": "dot_agent_bindings",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "operator_id": {
          "name": "operator_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "provider_kind": {
          "name": "provider_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'openai_dot'"
        },
        "generation": {
          "name": "generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pairing'"
        },
        "pairing_code_hash": {
          "name": "pairing_code_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "pairing_expires_at": {
          "name": "pairing_expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "dot_url": {
          "name": "dot_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "challenge_hash": {
          "name": "challenge_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "challenge_expires_at": {
          "name": "challenge_expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "ready_at": {
          "name": "ready_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "revoked_at": {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "dot_bindings_active_agent_uq": {
          "name": "dot_bindings_active_agent_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"dot_agent_bindings\".\"revoked_at\" IS NULL",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "dot_bindings_active_grant_uq": {
          "name": "dot_bindings_active_grant_uq",
          "columns": [
            {
              "expression": "grant_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"dot_agent_bindings\".\"revoked_at\" IS NULL AND \"dot_agent_bindings\".\"grant_id\" IS NOT NULL",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "dot_bindings_pairing_code_uq": {
          "name": "dot_bindings_pairing_code_uq",
          "columns": [
            {
              "expression": "pairing_code_hash",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "dot_agent_bindings_company_id_companies_id_fk": {
          "name": "dot_agent_bindings_company_id_companies_id_fk",
          "tableFrom": "dot_agent_bindings",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "dot_agent_bindings_agent_id_agents_id_fk": {
          "name": "dot_agent_bindings_agent_id_agents_id_fk",
          "tableFrom": "dot_agent_bindings",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "dot_agent_bindings_grant_id_mcp_oauth_grants_id_fk": {
          "name": "dot_agent_bindings_grant_id_mcp_oauth_grants_id_fk",
          "tableFrom": "dot_agent_bindings",
          "tableTo": "mcp_oauth_grants",
          "columnsFrom": [
            "grant_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.dot_mailbox_items": {
      "name": "dot_mailbox_items",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "bigserial",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "binding_id": {
          "name": "binding_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "binding_generation": {
          "name": "binding_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "assignment_id": {
          "name": "assignment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_event_id": {
          "name": "source_event_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "references": {
          "name": "references",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "dot_mailbox_event_uq": {
          "name": "dot_mailbox_event_uq",
          "columns": [
            {
              "expression": "binding_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "binding_generation",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_event_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "dot_mailbox_binding_cursor_idx": {
          "name": "dot_mailbox_binding_cursor_idx",
          "columns": [
            {
              "expression": "binding_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "binding_generation",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "dot_mailbox_items_company_id_companies_id_fk": {
          "name": "dot_mailbox_items_company_id_companies_id_fk",
          "tableFrom": "dot_mailbox_items",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "dot_mailbox_items_binding_id_dot_agent_bindings_id_fk": {
          "name": "dot_mailbox_items_binding_id_dot_agent_bindings_id_fk",
          "tableFrom": "dot_mailbox_items",
          "tableTo": "dot_agent_bindings",
          "columnsFrom": [
            "binding_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "dot_mailbox_items_assignment_id_dot_runner_assignments_id_fk": {
          "name": "dot_mailbox_items_assignment_id_dot_runner_assignments_id_fk",
          "tableFrom": "dot_mailbox_items",
          "tableTo": "dot_runner_assignments",
          "columnsFrom": [
            "assignment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.dot_runner_assignments": {
      "name": "dot_runner_assignments",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "binding_id": {
          "name": "binding_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "binding_generation": {
          "name": "binding_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "normalized_session_id": {
          "name": "normalized_session_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "turn_id": {
          "name": "turn_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "revision": {
          "name": "revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "controller_generation": {
          "name": "controller_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "catalog_digest": {
          "name": "catalog_digest",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "projection": {
          "name": "projection",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "accept_by": {
          "name": "accept_by",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "accepted_at": {
          "name": "accepted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "settled_at": {
          "name": "settled_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_activity_at": {
          "name": "last_activity_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "dot_assignments_turn_uq": {
          "name": "dot_assignments_turn_uq",
          "columns": [
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "turn_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "dot_assignments_active_binding_uq": {
          "name": "dot_assignments_active_binding_uq",
          "columns": [
            {
              "expression": "binding_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"dot_runner_assignments\".\"status\" IN ('offered', 'accepted')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "dot_assignments_company_idx": {
          "name": "dot_assignments_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "dot_runner_assignments_company_id_companies_id_fk": {
          "name": "dot_runner_assignments_company_id_companies_id_fk",
          "tableFrom": "dot_runner_assignments",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "dot_runner_assignments_binding_id_dot_agent_bindings_id_fk": {
          "name": "dot_runner_assignments_binding_id_dot_agent_bindings_id_fk",
          "tableFrom": "dot_runner_assignments",
          "tableTo": "dot_agent_bindings",
          "columnsFrom": [
            "binding_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "dot_runner_assignments_run_id_heartbeat_runs_id_fk": {
          "name": "dot_runner_assignments_run_id_heartbeat_runs_id_fk",
          "tableFrom": "dot_runner_assignments",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "dot_runner_assignments_agent_id_agents_id_fk": {
          "name": "dot_runner_assignments_agent_id_agents_id_fk",
          "tableFrom": "dot_runner_assignments",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.dot_runner_operations": {
      "name": "dot_runner_operations",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "assignment_id": {
          "name": "assignment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "request_id": {
          "name": "request_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "digest": {
          "name": "digest",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "command": {
          "name": "command",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'reserved'"
        },
        "outcome": {
          "name": "outcome",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "pending_returned_at": {
          "name": "pending_returned_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "observed_at": {
          "name": "observed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "source_event_id": {
          "name": "source_event_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "dot_operations_request_uq": {
          "name": "dot_operations_request_uq",
          "columns": [
            {
              "expression": "assignment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "request_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "dot_runner_operations_company_id_companies_id_fk": {
          "name": "dot_runner_operations_company_id_companies_id_fk",
          "tableFrom": "dot_runner_operations",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "dot_runner_operations_assignment_id_dot_runner_assignments_id_fk": {
          "name": "dot_runner_operations_assignment_id_dot_runner_assignments_id_fk",
          "tableFrom": "dot_runner_operations",
          "tableTo": "dot_runner_assignments",
          "columnsFrom": [
            "assignment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.email_endpoints": {
      "name": "email_endpoints",
      "schema": "",
      "columns": {
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "receive_mode": {
          "name": "receive_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "webhook_id": {
          "name": "webhook_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "owned_api_key_id": {
          "name": "owned_api_key_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "activation_at": {
          "name": "activation_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "sync_checkpoint": {
          "name": "sync_checkpoint",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_sync_at": {
          "name": "last_sync_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {},
      "foreignKeys": {
        "email_endpoints_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {
          "name": "email_endpoints_company_id_endpoint_id_chat_endpoints_company_id_id_fk",
          "tableFrom": "email_endpoints",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "email_endpoints_receive_mode_check": {
          "name": "email_endpoints_receive_mode_check",
          "value": "\"email_endpoints\".\"receive_mode\" in ('websocket', 'webhook')"
        }
      },
      "isRLSEnabled": false
    },
    "public.email_messages": {
      "name": "email_messages",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider_message_id": {
          "name": "provider_message_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "envelope": {
          "name": "envelope",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "text": {
          "name": "text",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "full_text": {
          "name": "full_text",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "''"
        },
        "direction": {
          "name": "direction",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "automatic": {
          "name": "automatic",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "attachment_ids": {
          "name": "attachment_ids",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "timestamp": {
          "name": "timestamp",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        }
      },
      "indexes": {
        "email_messages_provider_uq": {
          "name": "email_messages_provider_uq",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_message_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "email_messages_conversation_idx": {
          "name": "email_messages_conversation_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "conversation_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "timestamp",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "email_messages_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {
          "name": "email_messages_company_id_endpoint_id_chat_endpoints_company_id_id_fk",
          "tableFrom": "email_messages",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "email_messages_company_id_conversation_id_chat_conversations_company_id_id_fk": {
          "name": "email_messages_company_id_conversation_id_chat_conversations_company_id_id_fk",
          "tableFrom": "email_messages",
          "tableTo": "chat_conversations",
          "columnsFrom": [
            "company_id",
            "conversation_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "email_messages_direction_check": {
          "name": "email_messages_direction_check",
          "value": "\"email_messages\".\"direction\" in ('inbound', 'outbound')"
        }
      },
      "isRLSEnabled": false
    },
    "public.email_sends": {
      "name": "email_sends",
      "schema": "",
      "columns": {
        "publication_id": {
          "name": "publication_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "request": {
          "name": "request",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "actor": {
          "name": "actor",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "digest": {
          "name": "digest",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "outcome": {
          "name": "outcome",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'queued'"
        },
        "first_attempt_at": {
          "name": "first_attempt_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {
        "email_sends_pending_idx": {
          "name": "email_sends_pending_idx",
          "columns": [
            {
              "expression": "endpoint_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "outcome",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"email_sends\".\"outcome\" in ('queued', 'uncertain')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "email_sends_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {
          "name": "email_sends_company_id_endpoint_id_chat_endpoints_company_id_id_fk",
          "tableFrom": "email_sends",
          "tableTo": "chat_endpoints",
          "columnsFrom": [
            "company_id",
            "endpoint_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "email_sends_company_id_publication_id_chat_publications_company_id_id_fk": {
          "name": "email_sends_company_id_publication_id_chat_publications_company_id_id_fk",
          "tableFrom": "email_sends",
          "tableTo": "chat_publications",
          "columnsFrom": [
            "company_id",
            "publication_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "email_sends_outcome_check": {
          "name": "email_sends_outcome_check",
          "value": "\"email_sends\".\"outcome\" in ('queued', 'sent', 'delivered', 'failed', 'uncertain')"
        }
      },
      "isRLSEnabled": false
    },
    "public.environment_custom_image_setup_sessions": {
      "name": "environment_custom_image_setup_sessions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "environment_id": {
          "name": "environment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "template_id": {
          "name": "template_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "promoted_template_id": {
          "name": "promoted_template_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider_lease_id": {
          "name": "provider_lease_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "environment_lease_id": {
          "name": "environment_lease_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'starting'"
        },
        "started_by_user_id": {
          "name": "started_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "started_by_agent_id": {
          "name": "started_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "base_template_ref": {
          "name": "base_template_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "finished_at": {
          "name": "finished_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "failure_reason": {
          "name": "failure_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "connection_summary": {
          "name": "connection_summary",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "connection_secret_ref": {
          "name": "connection_secret_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "environment_custom_image_setup_sessions_environment_status_idx": {
          "name": "environment_custom_image_setup_sessions_environment_status_idx",
          "columns": [
            {
              "expression": "environment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_custom_image_setup_sessions_environment_active_uq": {
          "name": "environment_custom_image_setup_sessions_environment_active_uq",
          "columns": [
            {
              "expression": "environment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"environment_custom_image_setup_sessions\".\"status\" IN ('starting', 'waiting_for_user', 'capturing')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_custom_image_setup_sessions_template_idx": {
          "name": "environment_custom_image_setup_sessions_template_idx",
          "columns": [
            {
              "expression": "template_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_custom_image_setup_sessions_promoted_template_idx": {
          "name": "environment_custom_image_setup_sessions_promoted_template_idx",
          "columns": [
            {
              "expression": "promoted_template_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_custom_image_setup_sessions_expires_idx": {
          "name": "environment_custom_image_setup_sessions_expires_idx",
          "columns": [
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_custom_image_setup_sessions_provider_lease_idx": {
          "name": "environment_custom_image_setup_sessions_provider_lease_idx",
          "columns": [
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_lease_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "environment_custom_image_setup_sessions_environment_id_environments_id_fk": {
          "name": "environment_custom_image_setup_sessions_environment_id_environments_id_fk",
          "tableFrom": "environment_custom_image_setup_sessions",
          "tableTo": "environments",
          "columnsFrom": [
            "environment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "environment_custom_image_setup_sessions_template_id_environment_custom_image_templates_id_fk": {
          "name": "environment_custom_image_setup_sessions_template_id_environment_custom_image_templates_id_fk",
          "tableFrom": "environment_custom_image_setup_sessions",
          "tableTo": "environment_custom_image_templates",
          "columnsFrom": [
            "template_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "environment_custom_image_setup_sessions_promoted_template_id_environment_custom_image_templates_id_fk": {
          "name": "environment_custom_image_setup_sessions_promoted_template_id_environment_custom_image_templates_id_fk",
          "tableFrom": "environment_custom_image_setup_sessions",
          "tableTo": "environment_custom_image_templates",
          "columnsFrom": [
            "promoted_template_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "environment_custom_image_setup_sessions_environment_lease_id_environment_leases_id_fk": {
          "name": "environment_custom_image_setup_sessions_environment_lease_id_environment_leases_id_fk",
          "tableFrom": "environment_custom_image_setup_sessions",
          "tableTo": "environment_leases",
          "columnsFrom": [
            "environment_lease_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "environment_custom_image_setup_sessions_started_by_agent_id_agents_id_fk": {
          "name": "environment_custom_image_setup_sessions_started_by_agent_id_agents_id_fk",
          "tableFrom": "environment_custom_image_setup_sessions",
          "tableTo": "agents",
          "columnsFrom": [
            "started_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.environment_custom_image_templates": {
      "name": "environment_custom_image_templates",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "environment_id": {
          "name": "environment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "template_kind": {
          "name": "template_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'unknown'"
        },
        "template_ref": {
          "name": "template_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_template_ref": {
          "name": "source_template_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "source_environment_config_fingerprint": {
          "name": "source_environment_config_fingerprint",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "captured_at": {
          "name": "captured_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_used_at": {
          "name": "last_used_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "superseded_by_template_id": {
          "name": "superseded_by_template_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "environment_custom_image_templates_environment_status_idx": {
          "name": "environment_custom_image_templates_environment_status_idx",
          "columns": [
            {
              "expression": "environment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_custom_image_templates_environment_provider_status_idx": {
          "name": "environment_custom_image_templates_environment_provider_status_idx",
          "columns": [
            {
              "expression": "environment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_custom_image_templates_environment_active_uq": {
          "name": "environment_custom_image_templates_environment_active_uq",
          "columns": [
            {
              "expression": "environment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"environment_custom_image_templates\".\"status\" = 'active'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_custom_image_templates_superseded_by_idx": {
          "name": "environment_custom_image_templates_superseded_by_idx",
          "columns": [
            {
              "expression": "superseded_by_template_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_custom_image_templates_last_used_idx": {
          "name": "environment_custom_image_templates_last_used_idx",
          "columns": [
            {
              "expression": "last_used_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "environment_custom_image_templates_environment_id_environments_id_fk": {
          "name": "environment_custom_image_templates_environment_id_environments_id_fk",
          "tableFrom": "environment_custom_image_templates",
          "tableTo": "environments",
          "columnsFrom": [
            "environment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "environment_custom_image_templates_created_by_agent_id_agents_id_fk": {
          "name": "environment_custom_image_templates_created_by_agent_id_agents_id_fk",
          "tableFrom": "environment_custom_image_templates",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "environment_custom_image_templates_superseded_by_template_id_environment_custom_image_templates_id_fk": {
          "name": "environment_custom_image_templates_superseded_by_template_id_environment_custom_image_templates_id_fk",
          "tableFrom": "environment_custom_image_templates",
          "tableTo": "environment_custom_image_templates",
          "columnsFrom": [
            "superseded_by_template_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.environment_leases": {
      "name": "environment_leases",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "environment_id": {
          "name": "environment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "execution_workspace_id": {
          "name": "execution_workspace_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "heartbeat_run_id": {
          "name": "heartbeat_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "lease_policy": {
          "name": "lease_policy",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'ephemeral'"
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "provider_lease_id": {
          "name": "provider_lease_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "acquired_at": {
          "name": "acquired_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "last_used_at": {
          "name": "last_used_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "released_at": {
          "name": "released_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "failure_reason": {
          "name": "failure_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "cleanup_status": {
          "name": "cleanup_status",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "environment_leases_retained_recovery_adoption_idx": {
          "name": "environment_leases_retained_recovery_adoption_idx",
          "columns": [
            {
              "expression": "heartbeat_run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"environment_leases\".\"lease_policy\" = 'retain_on_failure'\n        and \"environment_leases\".\"heartbeat_run_id\" is not null\n        and not (coalesce(\"environment_leases\".\"metadata\", '{}'::jsonb) ? 'systemRecoveryAdoption')",
          "concurrently": true,
          "method": "btree",
          "with": {}
        },
        "environment_leases_company_environment_status_idx": {
          "name": "environment_leases_company_environment_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "environment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_leases_company_execution_workspace_idx": {
          "name": "environment_leases_company_execution_workspace_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "execution_workspace_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_leases_company_issue_idx": {
          "name": "environment_leases_company_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_leases_heartbeat_run_idx": {
          "name": "environment_leases_heartbeat_run_idx",
          "columns": [
            {
              "expression": "heartbeat_run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_leases_company_last_used_idx": {
          "name": "environment_leases_company_last_used_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "last_used_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environment_leases_provider_lease_idx": {
          "name": "environment_leases_provider_lease_idx",
          "columns": [
            {
              "expression": "provider_lease_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "environment_leases_company_id_companies_id_fk": {
          "name": "environment_leases_company_id_companies_id_fk",
          "tableFrom": "environment_leases",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "environment_leases_environment_id_environments_id_fk": {
          "name": "environment_leases_environment_id_environments_id_fk",
          "tableFrom": "environment_leases",
          "tableTo": "environments",
          "columnsFrom": [
            "environment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "environment_leases_execution_workspace_id_execution_workspaces_id_fk": {
          "name": "environment_leases_execution_workspace_id_execution_workspaces_id_fk",
          "tableFrom": "environment_leases",
          "tableTo": "execution_workspaces",
          "columnsFrom": [
            "execution_workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "environment_leases_issue_id_issues_id_fk": {
          "name": "environment_leases_issue_id_issues_id_fk",
          "tableFrom": "environment_leases",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "environment_leases_heartbeat_run_id_heartbeat_runs_id_fk": {
          "name": "environment_leases_heartbeat_run_id_heartbeat_runs_id_fk",
          "tableFrom": "environment_leases",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "heartbeat_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.environments": {
      "name": "environments",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "driver": {
          "name": "driver",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'local'"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "config": {
          "name": "config",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "env_vars": {
          "name": "env_vars",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "environments_status_idx": {
          "name": "environments_status_idx",
          "columns": [
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environments_local_driver_idx": {
          "name": "environments_local_driver_idx",
          "columns": [
            {
              "expression": "driver",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"environments\".\"driver\" = 'local'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environments_managed_sandbox_idx": {
          "name": "environments_managed_sandbox_idx",
          "columns": [
            {
              "expression": "driver",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"environments\".\"driver\" = 'sandbox' AND (\"environments\".\"metadata\" ->> 'managedByPaperclip')::boolean = true",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "environments_name_idx": {
          "name": "environments_name_idx",
          "columns": [
            {
              "expression": "name",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.execution_workspace_repositories": {
      "name": "execution_workspace_repositories",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "execution_workspace_id": {
          "name": "execution_workspace_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "requested_by_issue_id": {
          "name": "requested_by_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "repository_identity": {
          "name": "repository_identity",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "catalog_repository_id": {
          "name": "catalog_repository_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "repo_url": {
          "name": "repo_url",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "relative_path": {
          "name": "relative_path",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "requested_ref": {
          "name": "requested_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'HEAD'"
        },
        "pinned_commit": {
          "name": "pinned_commit",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "branch_name": {
          "name": "branch_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "request_key": {
          "name": "request_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "request_keys": {
          "name": "request_keys",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "failure_code": {
          "name": "failure_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "execution_workspace_repositories_identity_idx": {
          "name": "execution_workspace_repositories_identity_idx",
          "columns": [
            {
              "expression": "execution_workspace_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "repository_identity",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspace_repositories_path_idx": {
          "name": "execution_workspace_repositories_path_idx",
          "columns": [
            {
              "expression": "execution_workspace_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "relative_path",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspace_repositories_request_idx": {
          "name": "execution_workspace_repositories_request_idx",
          "columns": [
            {
              "expression": "execution_workspace_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "request_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspace_repositories_company_workspace_idx": {
          "name": "execution_workspace_repositories_company_workspace_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "execution_workspace_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "execution_workspace_repositories_company_id_companies_id_fk": {
          "name": "execution_workspace_repositories_company_id_companies_id_fk",
          "tableFrom": "execution_workspace_repositories",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "execution_workspace_repositories_execution_workspace_id_execution_workspaces_id_fk": {
          "name": "execution_workspace_repositories_execution_workspace_id_execution_workspaces_id_fk",
          "tableFrom": "execution_workspace_repositories",
          "tableTo": "execution_workspaces",
          "columnsFrom": [
            "execution_workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "execution_workspace_repositories_requested_by_issue_id_issues_id_fk": {
          "name": "execution_workspace_repositories_requested_by_issue_id_issues_id_fk",
          "tableFrom": "execution_workspace_repositories",
          "tableTo": "issues",
          "columnsFrom": [
            "requested_by_issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.execution_workspace_repository_access": {
      "name": "execution_workspace_repository_access",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "root_key": {
          "name": "root_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "canonical_cwd": {
          "name": "canonical_cwd",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "scope_id": {
          "name": "scope_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "execution_workspace_repository_access_scope_idx": {
          "name": "execution_workspace_repository_access_scope_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "root_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "scope_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "execution_workspace_repository_access_company_id_companies_id_fk": {
          "name": "execution_workspace_repository_access_company_id_companies_id_fk",
          "tableFrom": "execution_workspace_repository_access",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.execution_workspace_repository_roots": {
      "name": "execution_workspace_repository_roots",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "canonical_cwd": {
          "name": "canonical_cwd",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "root_key": {
          "name": "root_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "mode": {
          "name": "mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "execution_workspace_repository_roots_company_root_idx": {
          "name": "execution_workspace_repository_roots_company_root_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "root_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "execution_workspace_repository_roots_company_id_companies_id_fk": {
          "name": "execution_workspace_repository_roots_company_id_companies_id_fk",
          "tableFrom": "execution_workspace_repository_roots",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.execution_workspace_restore_points": {
      "name": "execution_workspace_restore_points",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "execution_workspace_id": {
          "name": "execution_workspace_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_issue_id": {
          "name": "source_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "generation": {
          "name": "generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "checkout_name": {
          "name": "checkout_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "''"
        },
        "object_key": {
          "name": "object_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "sha256": {
          "name": "sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "byte_size": {
          "name": "byte_size",
          "type": "bigint",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "activated_at": {
          "name": "activated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "tree_closed_at": {
          "name": "tree_closed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "delete_after": {
          "name": "delete_after",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "review_generation": {
          "name": "review_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "deleted_at": {
          "name": "deleted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_error": {
          "name": "last_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "execution_workspace_restore_points_object_key_uniq": {
          "name": "execution_workspace_restore_points_object_key_uniq",
          "columns": [
            {
              "expression": "object_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspace_restore_points_live_status_uniq": {
          "name": "execution_workspace_restore_points_live_status_uniq",
          "columns": [
            {
              "expression": "execution_workspace_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "generation",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "checkout_name",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"execution_workspace_restore_points\".\"status\" in ('pending', 'active', 'expiring')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspace_restore_points_status_delete_after_idx": {
          "name": "execution_workspace_restore_points_status_delete_after_idx",
          "columns": [
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "delete_after",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspace_restore_points_company_idx": {
          "name": "execution_workspace_restore_points_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspace_restore_points_source_issue_idx": {
          "name": "execution_workspace_restore_points_source_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspace_restore_points_active_source_idx": {
          "name": "execution_workspace_restore_points_active_source_idx",
          "columns": [
            {
              "expression": "source_issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"execution_workspace_restore_points\".\"status\" = 'active'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.execution_workspace_runtime_leases": {
      "name": "execution_workspace_runtime_leases",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "execution_workspace_id": {
          "name": "execution_workspace_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "owner_key": {
          "name": "owner_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "owner_issue_id": {
          "name": "owner_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "owner_run_id": {
          "name": "owner_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "owner_agent_id": {
          "name": "owner_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "last_action": {
          "name": "last_action",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "claimed_at": {
          "name": "claimed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "renewed_at": {
          "name": "renewed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "execution_workspace_runtime_leases_company_workspace_idx": {
          "name": "execution_workspace_runtime_leases_company_workspace_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "execution_workspace_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspace_runtime_leases_company_owner_idx": {
          "name": "execution_workspace_runtime_leases_company_owner_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "owner_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspace_runtime_leases_expires_at_idx": {
          "name": "execution_workspace_runtime_leases_expires_at_idx",
          "columns": [
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "execution_workspace_runtime_leases_company_id_companies_id_fk": {
          "name": "execution_workspace_runtime_leases_company_id_companies_id_fk",
          "tableFrom": "execution_workspace_runtime_leases",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "execution_workspace_runtime_leases_execution_workspace_id_execution_workspaces_id_fk": {
          "name": "execution_workspace_runtime_leases_execution_workspace_id_execution_workspaces_id_fk",
          "tableFrom": "execution_workspace_runtime_leases",
          "tableTo": "execution_workspaces",
          "columnsFrom": [
            "execution_workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "execution_workspace_runtime_leases_owner_issue_id_issues_id_fk": {
          "name": "execution_workspace_runtime_leases_owner_issue_id_issues_id_fk",
          "tableFrom": "execution_workspace_runtime_leases",
          "tableTo": "issues",
          "columnsFrom": [
            "owner_issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "execution_workspace_runtime_leases_owner_run_id_heartbeat_runs_id_fk": {
          "name": "execution_workspace_runtime_leases_owner_run_id_heartbeat_runs_id_fk",
          "tableFrom": "execution_workspace_runtime_leases",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "owner_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "execution_workspace_runtime_leases_owner_agent_id_agents_id_fk": {
          "name": "execution_workspace_runtime_leases_owner_agent_id_agents_id_fk",
          "tableFrom": "execution_workspace_runtime_leases",
          "tableTo": "agents",
          "columnsFrom": [
            "owner_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "execution_workspace_runtime_leases_execution_workspace_id_unique": {
          "name": "execution_workspace_runtime_leases_execution_workspace_id_unique",
          "nullsNotDistinct": false,
          "columns": [
            "execution_workspace_id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.execution_workspaces": {
      "name": "execution_workspaces",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "project_id": {
          "name": "project_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "project_workspace_id": {
          "name": "project_workspace_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "source_issue_id": {
          "name": "source_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "mode": {
          "name": "mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "strategy_type": {
          "name": "strategy_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "cwd": {
          "name": "cwd",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "repo_url": {
          "name": "repo_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "base_ref": {
          "name": "base_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "branch_name": {
          "name": "branch_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "provider_type": {
          "name": "provider_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'local_fs'"
        },
        "provider_ref": {
          "name": "provider_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "derived_from_execution_workspace_id": {
          "name": "derived_from_execution_workspace_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "last_used_at": {
          "name": "last_used_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "opened_at": {
          "name": "opened_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "closed_at": {
          "name": "closed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "cleanup_eligible_at": {
          "name": "cleanup_eligible_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "cleanup_reason": {
          "name": "cleanup_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "execution_workspaces_company_project_status_idx": {
          "name": "execution_workspaces_company_project_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "project_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspaces_company_project_workspace_status_idx": {
          "name": "execution_workspaces_company_project_workspace_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "project_workspace_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspaces_company_source_issue_idx": {
          "name": "execution_workspaces_company_source_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspaces_company_last_used_idx": {
          "name": "execution_workspaces_company_last_used_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "last_used_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "execution_workspaces_company_branch_idx": {
          "name": "execution_workspaces_company_branch_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "branch_name",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "execution_workspaces_company_id_companies_id_fk": {
          "name": "execution_workspaces_company_id_companies_id_fk",
          "tableFrom": "execution_workspaces",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "execution_workspaces_project_id_projects_id_fk": {
          "name": "execution_workspaces_project_id_projects_id_fk",
          "tableFrom": "execution_workspaces",
          "tableTo": "projects",
          "columnsFrom": [
            "project_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        },
        "execution_workspaces_project_workspace_id_project_workspaces_id_fk": {
          "name": "execution_workspaces_project_workspace_id_project_workspaces_id_fk",
          "tableFrom": "execution_workspaces",
          "tableTo": "project_workspaces",
          "columnsFrom": [
            "project_workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "execution_workspaces_source_issue_id_issues_id_fk": {
          "name": "execution_workspaces_source_issue_id_issues_id_fk",
          "tableFrom": "execution_workspaces",
          "tableTo": "issues",
          "columnsFrom": [
            "source_issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "execution_workspaces_derived_from_execution_workspace_id_execution_workspaces_id_fk": {
          "name": "execution_workspaces_derived_from_execution_workspace_id_execution_workspaces_id_fk",
          "tableFrom": "execution_workspaces",
          "tableTo": "execution_workspaces",
          "columnsFrom": [
            "derived_from_execution_workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.external_object_mentions": {
      "name": "external_object_mentions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_issue_id": {
          "name": "source_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_kind": {
          "name": "source_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_record_id": {
          "name": "source_record_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "document_key": {
          "name": "document_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "property_key": {
          "name": "property_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "matched_text_redacted": {
          "name": "matched_text_redacted",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "sanitized_display_url": {
          "name": "sanitized_display_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "canonical_identity_hash": {
          "name": "canonical_identity_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "canonical_identity": {
          "name": "canonical_identity",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "object_id": {
          "name": "object_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "provider_key": {
          "name": "provider_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "detector_key": {
          "name": "detector_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "object_type": {
          "name": "object_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "confidence": {
          "name": "confidence",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'exact'"
        },
        "created_by_plugin_id": {
          "name": "created_by_plugin_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "external_object_mentions_company_source_issue_idx": {
          "name": "external_object_mentions_company_source_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "external_object_mentions_company_object_idx": {
          "name": "external_object_mentions_company_object_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "object_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "external_object_mentions_company_provider_idx": {
          "name": "external_object_mentions_company_provider_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "object_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "external_object_mentions_company_source_record_uq": {
          "name": "external_object_mentions_company_source_record_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_record_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "document_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "property_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "canonical_identity_hash",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"external_object_mentions\".\"source_record_id\" is not null and \"external_object_mentions\".\"canonical_identity_hash\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "external_object_mentions_company_source_null_record_uq": {
          "name": "external_object_mentions_company_source_null_record_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "document_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "property_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "canonical_identity_hash",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"external_object_mentions\".\"source_record_id\" is null and \"external_object_mentions\".\"canonical_identity_hash\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "external_object_mentions_company_id_companies_id_fk": {
          "name": "external_object_mentions_company_id_companies_id_fk",
          "tableFrom": "external_object_mentions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "external_object_mentions_source_issue_id_issues_id_fk": {
          "name": "external_object_mentions_source_issue_id_issues_id_fk",
          "tableFrom": "external_object_mentions",
          "tableTo": "issues",
          "columnsFrom": [
            "source_issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "external_object_mentions_object_id_external_objects_id_fk": {
          "name": "external_object_mentions_object_id_external_objects_id_fk",
          "tableFrom": "external_object_mentions",
          "tableTo": "external_objects",
          "columnsFrom": [
            "object_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "external_object_mentions_created_by_plugin_id_plugins_id_fk": {
          "name": "external_object_mentions_created_by_plugin_id_plugins_id_fk",
          "tableFrom": "external_object_mentions",
          "tableTo": "plugins",
          "columnsFrom": [
            "created_by_plugin_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.external_objects": {
      "name": "external_objects",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "provider_key": {
          "name": "provider_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "plugin_id": {
          "name": "plugin_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "object_type": {
          "name": "object_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "external_id": {
          "name": "external_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "sanitized_canonical_url": {
          "name": "sanitized_canonical_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "canonical_identity_hash": {
          "name": "canonical_identity_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "display_key": {
          "name": "display_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "icon_key": {
          "name": "icon_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "display_title": {
          "name": "display_title",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status_key": {
          "name": "status_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status_label": {
          "name": "status_label",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status_icon_key": {
          "name": "status_icon_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status_category": {
          "name": "status_category",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'unknown'"
        },
        "status_tone": {
          "name": "status_tone",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'neutral'"
        },
        "liveness": {
          "name": "liveness",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'unknown'"
        },
        "is_terminal": {
          "name": "is_terminal",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "data": {
          "name": "data",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "remote_version": {
          "name": "remote_version",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "etag": {
          "name": "etag",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "last_resolved_at": {
          "name": "last_resolved_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_changed_at": {
          "name": "last_changed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_error_at": {
          "name": "last_error_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "next_refresh_at": {
          "name": "next_refresh_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "refresh_started_at": {
          "name": "refresh_started_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "refresh_token": {
          "name": "refresh_token",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "last_error_code": {
          "name": "last_error_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "last_error_message": {
          "name": "last_error_message",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "external_objects_company_provider_object_idx": {
          "name": "external_objects_company_provider_object_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "object_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "external_objects_company_provider_status_idx": {
          "name": "external_objects_company_provider_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status_category",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "external_objects_company_refresh_idx": {
          "name": "external_objects_company_refresh_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "next_refresh_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "external_objects_company_external_id_uq": {
          "name": "external_objects_company_external_id_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "object_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "external_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "external_objects_company_identity_uq": {
          "name": "external_objects_company_identity_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "provider_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "object_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "canonical_identity_hash",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "external_objects_company_id_companies_id_fk": {
          "name": "external_objects_company_id_companies_id_fk",
          "tableFrom": "external_objects",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "external_objects_plugin_id_plugins_id_fk": {
          "name": "external_objects_plugin_id_plugins_id_fk",
          "tableFrom": "external_objects",
          "tableTo": "plugins",
          "columnsFrom": [
            "plugin_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.company_fast_responses": {
      "name": "company_fast_responses",
      "schema": "",
      "columns": {
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "model": {
          "name": "model",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "enabled": {
          "name": "enabled",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "allow_sponsored": {
          "name": "allow_sponsored",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": true
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "company_fast_responses_company_id_companies_id_fk": {
          "name": "company_fast_responses_company_id_companies_id_fk",
          "tableFrom": "company_fast_responses",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "company_fast_responses_configured": {
          "name": "company_fast_responses_configured",
          "value": "(\"company_fast_responses\".\"connection_id\" is null) = (\"company_fast_responses\".\"grant_id\" is null) and (not \"company_fast_responses\".\"enabled\" or (\"company_fast_responses\".\"connection_id\" is not null and \"company_fast_responses\".\"model\" is not null))"
        }
      },
      "isRLSEnabled": false
    },
    "public.fast_response_requests": {
      "name": "fast_response_requests",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "source_key": {
          "name": "source_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source_comment_id": {
          "name": "source_comment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "project_id": {
          "name": "project_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "sponsored": {
          "name": "sponsored",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "endpoint_id": {
          "name": "endpoint_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "delivery_id": {
          "name": "delivery_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "session_generation": {
          "name": "session_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "publication_status": {
          "name": "publication_status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'pending'"
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "model": {
          "name": "model",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "provider_request_id": {
          "name": "provider_request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "cost_event_id": {
          "name": "cost_event_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "error_code": {
          "name": "error_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "comment_id": {
          "name": "comment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "accepted_at": {
          "name": "accepted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "started_at": {
          "name": "started_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "finished_at": {
          "name": "finished_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "duration_ms": {
          "name": "duration_ms",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "input_tokens": {
          "name": "input_tokens",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "output_tokens": {
          "name": "output_tokens",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {
        "fast_response_requests_source_idx": {
          "name": "fast_response_requests_source_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "fast_response_requests_history_idx": {
          "name": "fast_response_requests_history_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "accepted_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "fast_response_requests_work_idx": {
          "name": "fast_response_requests_work_idx",
          "columns": [
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"fast_response_requests\".\"status\" in ('pending', 'running')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "fast_response_requests_company_id_companies_id_fk": {
          "name": "fast_response_requests_company_id_companies_id_fk",
          "tableFrom": "fast_response_requests",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "fast_response_requests_cost_event_id_cost_events_id_fk": {
          "name": "fast_response_requests_cost_event_id_cost_events_id_fk",
          "tableFrom": "fast_response_requests",
          "tableTo": "cost_events",
          "columnsFrom": [
            "cost_event_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "fast_response_requests_status_check": {
          "name": "fast_response_requests_status_check",
          "value": "\"fast_response_requests\".\"status\" in ('pending', 'running', 'succeeded', 'failed', 'unknown', 'skipped')"
        }
      },
      "isRLSEnabled": false
    },
    "public.feedback_exports": {
      "name": "feedback_exports",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "feedback_vote_id": {
          "name": "feedback_vote_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "project_id": {
          "name": "project_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "author_user_id": {
          "name": "author_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "target_type": {
          "name": "target_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "target_id": {
          "name": "target_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "vote": {
          "name": "vote",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'local_only'"
        },
        "destination": {
          "name": "destination",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "export_id": {
          "name": "export_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "consent_version": {
          "name": "consent_version",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "schema_version": {
          "name": "schema_version",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'paperclip-feedback-envelope-v2'"
        },
        "bundle_version": {
          "name": "bundle_version",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'paperclip-feedback-bundle-v2'"
        },
        "payload_version": {
          "name": "payload_version",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'paperclip-feedback-v1'"
        },
        "payload_digest": {
          "name": "payload_digest",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "payload_snapshot": {
          "name": "payload_snapshot",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "target_summary": {
          "name": "target_summary",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "redaction_summary": {
          "name": "redaction_summary",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "attempt_count": {
          "name": "attempt_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "last_attempted_at": {
          "name": "last_attempted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "exported_at": {
          "name": "exported_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "failure_reason": {
          "name": "failure_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "feedback_exports_feedback_vote_idx": {
          "name": "feedback_exports_feedback_vote_idx",
          "columns": [
            {
              "expression": "feedback_vote_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "feedback_exports_company_created_idx": {
          "name": "feedback_exports_company_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "feedback_exports_company_status_idx": {
          "name": "feedback_exports_company_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "feedback_exports_company_issue_idx": {
          "name": "feedback_exports_company_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "feedback_exports_company_project_idx": {
          "name": "feedback_exports_company_project_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "project_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "feedback_exports_company_author_idx": {
          "name": "feedback_exports_company_author_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "author_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "feedback_exports_company_id_companies_id_fk": {
          "name": "feedback_exports_company_id_companies_id_fk",
          "tableFrom": "feedback_exports",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "feedback_exports_feedback_vote_id_feedback_votes_id_fk": {
          "name": "feedback_exports_feedback_vote_id_feedback_votes_id_fk",
          "tableFrom": "feedback_exports",
          "tableTo": "feedback_votes",
          "columnsFrom": [
            "feedback_vote_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "feedback_exports_issue_id_issues_id_fk": {
          "name": "feedback_exports_issue_id_issues_id_fk",
          "tableFrom": "feedback_exports",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "feedback_exports_project_id_projects_id_fk": {
          "name": "feedback_exports_project_id_projects_id_fk",
          "tableFrom": "feedback_exports",
          "tableTo": "projects",
          "columnsFrom": [
            "project_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.feedback_votes": {
      "name": "feedback_votes",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "target_type": {
          "name": "target_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "target_id": {
          "name": "target_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "author_user_id": {
          "name": "author_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "vote": {
          "name": "vote",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "reason": {
          "name": "reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "shared_with_labs": {
          "name": "shared_with_labs",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "shared_at": {
          "name": "shared_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "consent_version": {
          "name": "consent_version",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "redaction_summary": {
          "name": "redaction_summary",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "feedback_votes_company_issue_idx": {
          "name": "feedback_votes_company_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "feedback_votes_issue_target_idx": {
          "name": "feedback_votes_issue_target_idx",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "target_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "target_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "feedback_votes_author_idx": {
          "name": "feedback_votes_author_idx",
          "columns": [
            {
              "expression": "author_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "feedback_votes_company_target_author_idx": {
          "name": "feedback_votes_company_target_author_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "target_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "target_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "author_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "feedback_votes_company_id_companies_id_fk": {
          "name": "feedback_votes_company_id_companies_id_fk",
          "tableFrom": "feedback_votes",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "feedback_votes_issue_id_issues_id_fk": {
          "name": "feedback_votes_issue_id_issues_id_fk",
          "tableFrom": "feedback_votes",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.finance_events": {
      "name": "finance_events",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "project_id": {
          "name": "project_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "goal_id": {
          "name": "goal_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "heartbeat_run_id": {
          "name": "heartbeat_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "cost_event_id": {
          "name": "cost_event_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "receipt_hash": {
          "name": "receipt_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "billing_code": {
          "name": "billing_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "event_kind": {
          "name": "event_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "direction": {
          "name": "direction",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'debit'"
        },
        "biller": {
          "name": "biller",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "execution_adapter_type": {
          "name": "execution_adapter_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "pricing_tier": {
          "name": "pricing_tier",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "region": {
          "name": "region",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "model": {
          "name": "model",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "quantity": {
          "name": "quantity",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "unit": {
          "name": "unit",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "amount_cents": {
          "name": "amount_cents",
          "type": "numeric(24, 7)",
          "primaryKey": false,
          "notNull": true
        },
        "currency": {
          "name": "currency",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'USD'"
        },
        "estimated": {
          "name": "estimated",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "external_invoice_id": {
          "name": "external_invoice_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "metadata_json": {
          "name": "metadata_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "occurred_at": {
          "name": "occurred_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "finance_events_company_receipt_idx": {
          "name": "finance_events_company_receipt_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "finance_events_company_occurred_idx": {
          "name": "finance_events_company_occurred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "finance_events_company_biller_occurred_idx": {
          "name": "finance_events_company_biller_occurred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "biller",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "finance_events_company_kind_occurred_idx": {
          "name": "finance_events_company_kind_occurred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "event_kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "finance_events_company_direction_occurred_idx": {
          "name": "finance_events_company_direction_occurred_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "direction",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "occurred_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "finance_events_company_heartbeat_run_idx": {
          "name": "finance_events_company_heartbeat_run_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "heartbeat_run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "finance_events_company_cost_event_idx": {
          "name": "finance_events_company_cost_event_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "cost_event_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "finance_events_company_id_companies_id_fk": {
          "name": "finance_events_company_id_companies_id_fk",
          "tableFrom": "finance_events",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "finance_events_agent_id_agents_id_fk": {
          "name": "finance_events_agent_id_agents_id_fk",
          "tableFrom": "finance_events",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "finance_events_issue_id_issues_id_fk": {
          "name": "finance_events_issue_id_issues_id_fk",
          "tableFrom": "finance_events",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "finance_events_project_id_projects_id_fk": {
          "name": "finance_events_project_id_projects_id_fk",
          "tableFrom": "finance_events",
          "tableTo": "projects",
          "columnsFrom": [
            "project_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "finance_events_goal_id_goals_id_fk": {
          "name": "finance_events_goal_id_goals_id_fk",
          "tableFrom": "finance_events",
          "tableTo": "goals",
          "columnsFrom": [
            "goal_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "finance_events_heartbeat_run_id_heartbeat_runs_id_fk": {
          "name": "finance_events_heartbeat_run_id_heartbeat_runs_id_fk",
          "tableFrom": "finance_events",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "heartbeat_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "finance_events_cost_event_id_cost_events_id_fk": {
          "name": "finance_events_cost_event_id_cost_events_id_fk",
          "tableFrom": "finance_events",
          "tableTo": "cost_events",
          "columnsFrom": [
            "cost_event_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.folders": {
      "name": "folders",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "parent_id": {
          "name": "parent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "slug": {
          "name": "slug",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "system_key": {
          "name": "system_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "color": {
          "name": "color",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "position": {
          "name": "position",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "folders_company_kind_position_idx": {
          "name": "folders_company_kind_position_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "position",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "name",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "folders_company_kind_root_slug_uq": {
          "name": "folders_company_kind_root_slug_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "slug",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"folders\".\"parent_id\" is null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "folders_company_kind_parent_slug_uq": {
          "name": "folders_company_kind_parent_slug_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "parent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "slug",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"folders\".\"parent_id\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "folders_company_kind_system_key_uq": {
          "name": "folders_company_kind_system_key_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "system_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"folders\".\"system_key\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "folders_company_kind_parent_position_idx": {
          "name": "folders_company_kind_parent_position_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "parent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "position",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "name",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "folders_company_id_companies_id_fk": {
          "name": "folders_company_id_companies_id_fk",
          "tableFrom": "folders",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "folders_parent_id_folders_id_fk": {
          "name": "folders_parent_id_folders_id_fk",
          "tableFrom": "folders",
          "tableTo": "folders",
          "columnsFrom": [
            "parent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "restrict",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.goals": {
      "name": "goals",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "level": {
          "name": "level",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'task'"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'planned'"
        },
        "parent_id": {
          "name": "parent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "owner_agent_id": {
          "name": "owner_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "goals_company_idx": {
          "name": "goals_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "goals_company_id_companies_id_fk": {
          "name": "goals_company_id_companies_id_fk",
          "tableFrom": "goals",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "goals_parent_id_goals_id_fk": {
          "name": "goals_parent_id_goals_id_fk",
          "tableFrom": "goals",
          "tableTo": "goals",
          "columnsFrom": [
            "parent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "goals_owner_agent_id_agents_id_fk": {
          "name": "goals_owner_agent_id_agents_id_fk",
          "tableFrom": "goals",
          "tableTo": "agents",
          "columnsFrom": [
            "owner_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.grok_bot_dispatches": {
      "name": "grok_bot_dispatches",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "routine_id": {
          "name": "routine_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "binding_id": {
          "name": "binding_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "binding_generation": {
          "name": "binding_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "routine_revision": {
          "name": "routine_revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "assignment_id": {
          "name": "assignment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "source_event_id": {
          "name": "source_event_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "payload": {
          "name": "payload",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true
        },
        "challenge_hash": {
          "name": "challenge_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'prepared'"
        },
        "http_status": {
          "name": "http_status",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "sent_at": {
          "name": "sent_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "acknowledged_at": {
          "name": "acknowledged_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "grok_dispatch_event_uq": {
          "name": "grok_dispatch_event_uq",
          "columns": [
            {
              "expression": "binding_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "binding_generation",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "routine_revision",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_event_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "grok_dispatch_company_status_idx": {
          "name": "grok_dispatch_company_status_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "grok_dispatch_assignment_kind_idx": {
          "name": "grok_dispatch_assignment_kind_idx",
          "columns": [
            {
              "expression": "assignment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "kind",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "grok_bot_dispatches_company_id_companies_id_fk": {
          "name": "grok_bot_dispatches_company_id_companies_id_fk",
          "tableFrom": "grok_bot_dispatches",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "grok_bot_dispatches_routine_id_grok_bot_routines_id_fk": {
          "name": "grok_bot_dispatches_routine_id_grok_bot_routines_id_fk",
          "tableFrom": "grok_bot_dispatches",
          "tableTo": "grok_bot_routines",
          "columnsFrom": [
            "routine_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "grok_bot_dispatches_binding_id_dot_agent_bindings_id_fk": {
          "name": "grok_bot_dispatches_binding_id_dot_agent_bindings_id_fk",
          "tableFrom": "grok_bot_dispatches",
          "tableTo": "dot_agent_bindings",
          "columnsFrom": [
            "binding_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "grok_bot_dispatches_grant_id_mcp_oauth_grants_id_fk": {
          "name": "grok_bot_dispatches_grant_id_mcp_oauth_grants_id_fk",
          "tableFrom": "grok_bot_dispatches",
          "tableTo": "mcp_oauth_grants",
          "columnsFrom": [
            "grant_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "grok_bot_dispatches_assignment_id_dot_runner_assignments_id_fk": {
          "name": "grok_bot_dispatches_assignment_id_dot_runner_assignments_id_fk",
          "tableFrom": "grok_bot_dispatches",
          "tableTo": "dot_runner_assignments",
          "columnsFrom": [
            "assignment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.grok_bot_routines": {
      "name": "grok_bot_routines",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "binding_id": {
          "name": "binding_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "binding_generation": {
          "name": "binding_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "bot_name": {
          "name": "bot_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "secret_id": {
          "name": "secret_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "secret_version": {
          "name": "secret_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "revision": {
          "name": "revision",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "verified_grant_id": {
          "name": "verified_grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "verified_at": {
          "name": "verified_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_contact_at": {
          "name": "last_contact_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "recovery_required_at": {
          "name": "recovery_required_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "recovery_reason": {
          "name": "recovery_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "grok_routines_binding_uq": {
          "name": "grok_routines_binding_uq",
          "columns": [
            {
              "expression": "binding_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "grok_routines_company_agent_idx": {
          "name": "grok_routines_company_agent_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "grok_bot_routines_company_id_companies_id_fk": {
          "name": "grok_bot_routines_company_id_companies_id_fk",
          "tableFrom": "grok_bot_routines",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "grok_bot_routines_agent_id_agents_id_fk": {
          "name": "grok_bot_routines_agent_id_agents_id_fk",
          "tableFrom": "grok_bot_routines",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "grok_bot_routines_binding_id_dot_agent_bindings_id_fk": {
          "name": "grok_bot_routines_binding_id_dot_agent_bindings_id_fk",
          "tableFrom": "grok_bot_routines",
          "tableTo": "dot_agent_bindings",
          "columnsFrom": [
            "binding_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "grok_bot_routines_secret_id_company_secrets_id_fk": {
          "name": "grok_bot_routines_secret_id_company_secrets_id_fk",
          "tableFrom": "grok_bot_routines",
          "tableTo": "company_secrets",
          "columnsFrom": [
            "secret_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "grok_bot_routines_verified_grant_id_mcp_oauth_grants_id_fk": {
          "name": "grok_bot_routines_verified_grant_id_mcp_oauth_grants_id_fk",
          "tableFrom": "grok_bot_routines",
          "tableTo": "mcp_oauth_grants",
          "columnsFrom": [
            "verified_grant_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.heartbeat_run_events": {
      "name": "heartbeat_run_events",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "bigserial",
          "primaryKey": true,
          "notNull": true
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "seq": {
          "name": "seq",
          "type": "bigint",
          "primaryKey": false,
          "notNull": true
        },
        "event_type": {
          "name": "event_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "stream": {
          "name": "stream",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "level": {
          "name": "level",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "color": {
          "name": "color",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "message": {
          "name": "message",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "payload": {
          "name": "payload",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "source_instance_id": {
          "name": "source_instance_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "source_event_id": {
          "name": "source_event_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "source_seq": {
          "name": "source_seq",
          "type": "bigint",
          "primaryKey": false,
          "notNull": false
        },
        "source_payload_sha256": {
          "name": "source_payload_sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "protocol_schema_version": {
          "name": "protocol_schema_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "heartbeat_run_events_run_seq_uq": {
          "name": "heartbeat_run_events_run_seq_uq",
          "columns": [
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "seq",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_run_events_run_source_event_uq": {
          "name": "heartbeat_run_events_run_source_event_uq",
          "columns": [
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_event_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"heartbeat_run_events\".\"source_event_id\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_run_events_run_source_seq_uq": {
          "name": "heartbeat_run_events_run_source_seq_uq",
          "columns": [
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_instance_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "source_seq",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"heartbeat_run_events\".\"source_instance_id\" is not null and \"heartbeat_run_events\".\"source_seq\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_run_events_company_run_idx": {
          "name": "heartbeat_run_events_company_run_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_run_events_company_created_idx": {
          "name": "heartbeat_run_events_company_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "heartbeat_run_events_company_id_companies_id_fk": {
          "name": "heartbeat_run_events_company_id_companies_id_fk",
          "tableFrom": "heartbeat_run_events",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "heartbeat_run_events_run_id_heartbeat_runs_id_fk": {
          "name": "heartbeat_run_events_run_id_heartbeat_runs_id_fk",
          "tableFrom": "heartbeat_run_events",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "heartbeat_run_events_agent_id_agents_id_fk": {
          "name": "heartbeat_run_events_agent_id_agents_id_fk",
          "tableFrom": "heartbeat_run_events",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.heartbeat_run_watchdog_decisions": {
      "name": "heartbeat_run_watchdog_decisions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "evaluation_issue_id": {
          "name": "evaluation_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "decision": {
          "name": "decision",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "snoozed_until": {
          "name": "snoozed_until",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "reason": {
          "name": "reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_run_id": {
          "name": "created_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "heartbeat_run_watchdog_decisions_company_run_created_idx": {
          "name": "heartbeat_run_watchdog_decisions_company_run_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_run_watchdog_decisions_company_run_snooze_idx": {
          "name": "heartbeat_run_watchdog_decisions_company_run_snooze_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "snoozed_until",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "heartbeat_run_watchdog_decisions_company_id_companies_id_fk": {
          "name": "heartbeat_run_watchdog_decisions_company_id_companies_id_fk",
          "tableFrom": "heartbeat_run_watchdog_decisions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "heartbeat_run_watchdog_decisions_run_id_heartbeat_runs_id_fk": {
          "name": "heartbeat_run_watchdog_decisions_run_id_heartbeat_runs_id_fk",
          "tableFrom": "heartbeat_run_watchdog_decisions",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "heartbeat_run_watchdog_decisions_evaluation_issue_id_issues_id_fk": {
          "name": "heartbeat_run_watchdog_decisions_evaluation_issue_id_issues_id_fk",
          "tableFrom": "heartbeat_run_watchdog_decisions",
          "tableTo": "issues",
          "columnsFrom": [
            "evaluation_issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "heartbeat_run_watchdog_decisions_created_by_agent_id_agents_id_fk": {
          "name": "heartbeat_run_watchdog_decisions_created_by_agent_id_agents_id_fk",
          "tableFrom": "heartbeat_run_watchdog_decisions",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "heartbeat_run_watchdog_decisions_created_by_run_id_heartbeat_runs_id_fk": {
          "name": "heartbeat_run_watchdog_decisions_created_by_run_id_heartbeat_runs_id_fk",
          "tableFrom": "heartbeat_run_watchdog_decisions",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "created_by_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.heartbeat_runs": {
      "name": "heartbeat_runs",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "scope_kind": {
          "name": "scope_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'company'"
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "invocation_source": {
          "name": "invocation_source",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'on_demand'"
        },
        "trigger_detail": {
          "name": "trigger_detail",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'queued'"
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "active_identity_context_id": {
          "name": "active_identity_context_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "started_at": {
          "name": "started_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "finished_at": {
          "name": "finished_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "execution_control_deadline_at": {
          "name": "execution_control_deadline_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "execution_status_delivery_id": {
          "name": "execution_status_delivery_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "error": {
          "name": "error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "wakeup_request_id": {
          "name": "wakeup_request_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "exit_code": {
          "name": "exit_code",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "signal": {
          "name": "signal",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "cost_accounting_pending": {
          "name": "cost_accounting_pending",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "cost_accounted_at": {
          "name": "cost_accounted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "accounting_projection_version": {
          "name": "accounting_projection_version",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "accounting_last_attempt_at": {
          "name": "accounting_last_attempt_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "accounting_last_error": {
          "name": "accounting_last_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "accounting_attempt_count": {
          "name": "accounting_attempt_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "usage_json": {
          "name": "usage_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "result_json": {
          "name": "result_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "runtime_mode": {
          "name": "runtime_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'legacy'"
        },
        "runtime_mode_resolver_version": {
          "name": "runtime_mode_resolver_version",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "runtime_mode_reason": {
          "name": "runtime_mode_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "runtime_mode_resolved_at": {
          "name": "runtime_mode_resolved_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "runner_profile_json": {
          "name": "runner_profile_json",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "runner_instance_id": {
          "name": "runner_instance_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "native_session_id": {
          "name": "native_session_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "native_issue_id": {
          "name": "native_issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "driver_kind": {
          "name": "driver_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "driver_version": {
          "name": "driver_version",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "completion_contract_id": {
          "name": "completion_contract_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "completion_contract_sha256": {
          "name": "completion_contract_sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "next_event_seq": {
          "name": "next_event_seq",
          "type": "bigint",
          "primaryKey": false,
          "notNull": true,
          "default": 1
        },
        "native_phase": {
          "name": "native_phase",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "native_phase_updated_at": {
          "name": "native_phase_updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "session_id_before": {
          "name": "session_id_before",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "session_id_after": {
          "name": "session_id_after",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "log_store": {
          "name": "log_store",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "log_ref": {
          "name": "log_ref",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "log_bytes": {
          "name": "log_bytes",
          "type": "bigint",
          "primaryKey": false,
          "notNull": false
        },
        "log_sha256": {
          "name": "log_sha256",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "log_compressed": {
          "name": "log_compressed",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "stdout_excerpt": {
          "name": "stdout_excerpt",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "stderr_excerpt": {
          "name": "stderr_excerpt",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "error_code": {
          "name": "error_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "external_run_id": {
          "name": "external_run_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "controller_boot_id": {
          "name": "controller_boot_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "controller_lease_expires_at": {
          "name": "controller_lease_expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "execution_stage": {
          "name": "execution_stage",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "process_pid": {
          "name": "process_pid",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "process_group_id": {
          "name": "process_group_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "process_started_at": {
          "name": "process_started_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_output_at": {
          "name": "last_output_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "last_output_seq": {
          "name": "last_output_seq",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "last_output_stream": {
          "name": "last_output_stream",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "last_output_bytes": {
          "name": "last_output_bytes",
          "type": "bigint",
          "primaryKey": false,
          "notNull": false
        },
        "retry_of_run_id": {
          "name": "retry_of_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "process_loss_retry_count": {
          "name": "process_loss_retry_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "scheduled_retry_at": {
          "name": "scheduled_retry_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "scheduled_retry_attempt": {
          "name": "scheduled_retry_attempt",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "scheduled_retry_reason": {
          "name": "scheduled_retry_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "issue_comment_status": {
          "name": "issue_comment_status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'not_applicable'"
        },
        "issue_comment_satisfied_by_comment_id": {
          "name": "issue_comment_satisfied_by_comment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "issue_comment_retry_queued_at": {
          "name": "issue_comment_retry_queued_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "liveness_state": {
          "name": "liveness_state",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "liveness_reason": {
          "name": "liveness_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "continuation_attempt": {
          "name": "continuation_attempt",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "last_useful_action_at": {
          "name": "last_useful_action_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "next_action": {
          "name": "next_action",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "context_snapshot": {
          "name": "context_snapshot",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "heartbeat_runs_retained_recovery_adoption_idx": {
          "name": "heartbeat_runs_retained_recovery_adoption_idx",
          "columns": [
            {
              "expression": "id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"heartbeat_runs\".\"result_json\"->'workspaceRestoreRecovery'->>'schema' = 'paperclip.workspace-restore-recovery.v1'\n        and not (coalesce(\"heartbeat_runs\".\"result_json\", '{}'::jsonb) ? 'systemRecoveryAdoption')\n        and \"heartbeat_runs\".\"status\" in ('failed', 'interrupted', 'timed_out', 'cancelled', 'succeeded')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_cost_accounting_pending_idx": {
          "name": "heartbeat_runs_cost_accounting_pending_idx",
          "columns": [
            {
              "expression": "updated_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"heartbeat_runs\".\"cost_accounting_pending\" = true",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_cost_data_quality_idx": {
          "name": "heartbeat_runs_cost_data_quality_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "coalesce(\"finished_at\", \"created_at\") desc",
              "asc": true,
              "isExpression": true,
              "nulls": "last"
            },
            {
              "expression": "id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"heartbeat_runs\".\"cost_accounting_pending\" = true and \"heartbeat_runs\".\"status\" in ('succeeded','failed','timed_out','cancelled','interrupted')",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_execution_status_delivery_idx": {
          "name": "heartbeat_runs_execution_status_delivery_idx",
          "columns": [
            {
              "expression": "execution_status_delivery_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"heartbeat_runs\".\"execution_status_delivery_id\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_execution_control_deadline_idx": {
          "name": "heartbeat_runs_execution_control_deadline_idx",
          "columns": [
            {
              "expression": "execution_control_deadline_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "where": "\"heartbeat_runs\".\"execution_control_deadline_at\" is not null",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_native_replacement_predecessor_uq": {
          "name": "heartbeat_runs_native_replacement_predecessor_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "retry_of_run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"heartbeat_runs\".\"scheduled_retry_reason\" = 'native_safe_replacement'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_agent_started_idx": {
          "name": "heartbeat_runs_company_agent_started_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "started_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_issue_created_idx": {
          "name": "heartbeat_runs_company_issue_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_responsible_user_idx": {
          "name": "heartbeat_runs_company_responsible_user_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "responsible_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_liveness_idx": {
          "name": "heartbeat_runs_company_liveness_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "liveness_state",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_status_last_output_idx": {
          "name": "heartbeat_runs_company_status_last_output_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "last_output_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_status_process_started_idx": {
          "name": "heartbeat_runs_company_status_process_started_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "status",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "process_started_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_created_at_desc_idx": {
          "name": "heartbeat_runs_company_created_at_desc_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": false,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_ctx_issue_created_idx": {
          "name": "heartbeat_runs_company_ctx_issue_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "(\"context_snapshot\" ->> 'issueId')",
              "asc": true,
              "isExpression": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": false,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_ctx_task_created_idx": {
          "name": "heartbeat_runs_company_ctx_task_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "(\"context_snapshot\" ->> 'taskId')",
              "asc": true,
              "isExpression": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": false,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_ctx_taskkey_created_idx": {
          "name": "heartbeat_runs_company_ctx_taskkey_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "(\"context_snapshot\" ->> 'taskKey')",
              "asc": true,
              "isExpression": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": false,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_ctx_paperclip_issue_created_idx": {
          "name": "heartbeat_runs_company_ctx_paperclip_issue_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "(\"context_snapshot\" -> 'paperclipIssue' ->> 'id')",
              "asc": true,
              "isExpression": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": false,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": true,
          "method": "btree",
          "with": {}
        },
        "heartbeat_runs_company_origin_issue_idx": {
          "name": "heartbeat_runs_company_origin_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "coalesce(\n        \"native_issue_id\"::text,\n        nullif(\"context_snapshot\"->>'issueId', ''),\n        nullif(\"context_snapshot\"->>'taskId', ''),\n        nullif(\"context_snapshot\"->>'taskKey', '')\n      )",
              "asc": true,
              "isExpression": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": true,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "heartbeat_runs_company_id_companies_id_fk": {
          "name": "heartbeat_runs_company_id_companies_id_fk",
          "tableFrom": "heartbeat_runs",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "heartbeat_runs_agent_id_agents_id_fk": {
          "name": "heartbeat_runs_agent_id_agents_id_fk",
          "tableFrom": "heartbeat_runs",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "heartbeat_runs_issue_id_issues_id_fk": {
          "name": "heartbeat_runs_issue_id_issues_id_fk",
          "tableFrom": "heartbeat_runs",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "heartbeat_runs_wakeup_request_id_agent_wakeup_requests_id_fk": {
          "name": "heartbeat_runs_wakeup_request_id_agent_wakeup_requests_id_fk",
          "tableFrom": "heartbeat_runs",
          "tableTo": "agent_wakeup_requests",
          "columnsFrom": [
            "wakeup_request_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "heartbeat_runs_retry_of_run_id_heartbeat_runs_id_fk": {
          "name": "heartbeat_runs_retry_of_run_id_heartbeat_runs_id_fk",
          "tableFrom": "heartbeat_runs",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "retry_of_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "heartbeat_runs_company_native_issue_id_uq": {
          "name": "heartbeat_runs_company_native_issue_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "native_issue_id",
            "id"
          ]
        },
        "heartbeat_runs_company_native_issue_contract_id_uq": {
          "name": "heartbeat_runs_company_native_issue_contract_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "native_issue_id",
            "id",
            "completion_contract_id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "heartbeat_runs_scope_binding_check": {
          "name": "heartbeat_runs_scope_binding_check",
          "value": "(\"heartbeat_runs\".\"scope_kind\" = 'company' AND \"heartbeat_runs\".\"issue_id\" IS NULL)\n        OR \"heartbeat_runs\".\"scope_kind\" = 'issue'"
        }
      },
      "isRLSEnabled": false
    },
    "public.inbox_dismissals": {
      "name": "inbox_dismissals",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "item_key": {
          "name": "item_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'dismiss'"
        },
        "dismissed_at": {
          "name": "dismissed_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "snoozed_until": {
          "name": "snoozed_until",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "inbox_dismissals_company_user_idx": {
          "name": "inbox_dismissals_company_user_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "inbox_dismissals_company_item_idx": {
          "name": "inbox_dismissals_company_item_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "item_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "inbox_dismissals_company_user_item_idx": {
          "name": "inbox_dismissals_company_user_item_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "item_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "inbox_dismissals_company_id_companies_id_fk": {
          "name": "inbox_dismissals_company_id_companies_id_fk",
          "tableFrom": "inbox_dismissals",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.connection_grant_delegations": {
      "name": "connection_grant_delegations",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "connection_grant_delegations_company_agent_idx": {
          "name": "connection_grant_delegations_company_agent_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "connection_grant_delegations_grant_agent_uq": {
          "name": "connection_grant_delegations_grant_agent_uq",
          "columns": [
            {
              "expression": "grant_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "connection_grant_delegations_company_id_companies_id_fk": {
          "name": "connection_grant_delegations_company_id_companies_id_fk",
          "tableFrom": "connection_grant_delegations",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "connection_grant_delegations_agent_id_agents_id_fk": {
          "name": "connection_grant_delegations_agent_id_agents_id_fk",
          "tableFrom": "connection_grant_delegations",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "connection_grant_delegations_company_grant_fk": {
          "name": "connection_grant_delegations_company_grant_fk",
          "tableFrom": "connection_grant_delegations",
          "tableTo": "connection_grants",
          "columnsFrom": [
            "company_id",
            "grant_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.connection_grant_members": {
      "name": "connection_grant_members",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "grant_id": {
          "name": "grant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "subject_type": {
          "name": "subject_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "subject_id": {
          "name": "subject_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "connection_grant_members_company_subject_idx": {
          "name": "connection_grant_members_company_subject_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "subject_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "subject_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "connection_grant_members_grant_subject_uq": {
          "name": "connection_grant_members_grant_subject_uq",
          "columns": [
            {
              "expression": "grant_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "subject_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "subject_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "connection_grant_members_company_id_companies_id_fk": {
          "name": "connection_grant_members_company_id_companies_id_fk",
          "tableFrom": "connection_grant_members",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "connection_grant_members_company_grant_fk": {
          "name": "connection_grant_members_company_grant_fk",
          "tableFrom": "connection_grant_members",
          "tableTo": "connection_grants",
          "columnsFrom": [
            "company_id",
            "grant_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "connection_grant_members_subject_type_check": {
          "name": "connection_grant_members_subject_type_check",
          "value": "\"connection_grant_members\".\"subject_type\" in ('user')"
        }
      },
      "isRLSEnabled": false
    },
    "public.connection_grants": {
      "name": "connection_grants",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "subject_user_id": {
          "name": "subject_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "subject_agent_id": {
          "name": "subject_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "provider_tenant": {
          "name": "provider_tenant",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "credential_secret_refs": {
          "name": "credential_secret_refs",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "external_credential": {
          "name": "external_credential",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "is_default": {
          "name": "is_default",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_user_id": {
          "name": "created_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "revoked_at": {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "revoked_by_agent_id": {
          "name": "revoked_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "revoked_by_user_id": {
          "name": "revoked_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "last_used_at": {
          "name": "last_used_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "connection_grants_company_connection_idx": {
          "name": "connection_grants_company_connection_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "connection_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "connection_grants_subject_user_idx": {
          "name": "connection_grants_subject_user_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "subject_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "connection_grants_subject_agent_idx": {
          "name": "connection_grants_subject_agent_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "subject_agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "connection_grants_user_uq": {
          "name": "connection_grants_user_uq",
          "columns": [
            {
              "expression": "connection_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "subject_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "connection_grants_agent_uq": {
          "name": "connection_grants_agent_uq",
          "columns": [
            {
              "expression": "connection_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "subject_agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "connection_grants_default_uq": {
          "name": "connection_grants_default_uq",
          "columns": [
            {
              "expression": "connection_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "where": "\"connection_grants\".\"is_default\" = true and \"connection_grants\".\"kind\" = 'organization'",
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "connection_grants_company_id_companies_id_fk": {
          "name": "connection_grants_company_id_companies_id_fk",
          "tableFrom": "connection_grants",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "connection_grants_subject_agent_id_agents_id_fk": {
          "name": "connection_grants_subject_agent_id_agents_id_fk",
          "tableFrom": "connection_grants",
          "tableTo": "agents",
          "columnsFrom": [
            "subject_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "connection_grants_created_by_agent_id_agents_id_fk": {
          "name": "connection_grants_created_by_agent_id_agents_id_fk",
          "tableFrom": "connection_grants",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "connection_grants_revoked_by_agent_id_agents_id_fk": {
          "name": "connection_grants_revoked_by_agent_id_agents_id_fk",
          "tableFrom": "connection_grants",
          "tableTo": "agents",
          "columnsFrom": [
            "revoked_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "connection_grants_company_connection_fk": {
          "name": "connection_grants_company_connection_fk",
          "tableFrom": "connection_grants",
          "tableTo": "tool_connections",
          "columnsFrom": [
            "company_id",
            "connection_id"
          ],
          "columnsTo": [
            "company_id",
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "connection_grants_company_id_uq": {
          "name": "connection_grants_company_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {
        "connection_grants_kind_check": {
          "name": "connection_grants_kind_check",
          "value": "\"connection_grants\".\"kind\" in ('organization', 'user', 'agent')"
        },
        "connection_grants_status_check": {
          "name": "connection_grants_status_check",
          "value": "\"connection_grants\".\"status\" in ('active', 'revoked', 'expired', 'needs_reauthorization')"
        },
        "connection_grants_credential_source_one_of_check": {
          "name": "connection_grants_credential_source_one_of_check",
          "value": "\"connection_grants\".\"external_credential\" is null or jsonb_array_length(\"connection_grants\".\"credential_secret_refs\") = 0"
        },
        "connection_grants_subject_check": {
          "name": "connection_grants_subject_check",
          "value": "(\"connection_grants\".\"kind\" = 'user' and \"connection_grants\".\"subject_user_id\" is not null and \"connection_grants\".\"subject_agent_id\" is null) or (\"connection_grants\".\"kind\" = 'agent' and \"connection_grants\".\"subject_agent_id\" is not null and \"connection_grants\".\"subject_user_id\" is null) or (\"connection_grants\".\"kind\" = 'organization' and \"connection_grants\".\"subject_user_id\" is null and \"connection_grants\".\"subject_agent_id\" is null)"
        },
        "connection_grants_default_check": {
          "name": "connection_grants_default_check",
          "value": "\"connection_grants\".\"is_default\" = false or \"connection_grants\".\"kind\" = 'organization'"
        }
      },
      "isRLSEnabled": false
    },
    "public.connection_token_issuances": {
      "name": "connection_token_issuances",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "application_id": {
          "name": "application_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "connection_id": {
          "name": "connection_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "agent_id": {
          "name": "agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "run_id": {
          "name": "run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "project_id": {
          "name": "project_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "responsible_user_id": {
          "name": "responsible_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "path": {
          "name": "path",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "requested_scope": {
          "name": "requested_scope",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "issued_scope": {
          "name": "issued_scope",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'[]'::jsonb"
        },
        "ttl_seconds": {
          "name": "ttl_seconds",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "token_hash": {
          "name": "token_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "outcome": {
          "name": "outcome",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "error_code": {
          "name": "error_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "connection_token_issuances_company_created_idx": {
          "name": "connection_token_issuances_company_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "connection_token_issuances_connection_created_idx": {
          "name": "connection_token_issuances_connection_created_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "connection_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "connection_token_issuances_agent_connection_idx": {
          "name": "connection_token_issuances_agent_connection_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "agent_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "connection_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "connection_token_issuances_run_idx": {
          "name": "connection_token_issuances_run_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "connection_token_issuances_company_id_companies_id_fk": {
          "name": "connection_token_issuances_company_id_companies_id_fk",
          "tableFrom": "connection_token_issuances",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "connection_token_issuances_application_id_tool_applications_id_fk": {
          "name": "connection_token_issuances_application_id_tool_applications_id_fk",
          "tableFrom": "connection_token_issuances",
          "tableTo": "tool_applications",
          "columnsFrom": [
            "application_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "connection_token_issuances_connection_id_tool_connections_id_fk": {
          "name": "connection_token_issuances_connection_id_tool_connections_id_fk",
          "tableFrom": "connection_token_issuances",
          "tableTo": "tool_connections",
          "columnsFrom": [
            "connection_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "connection_token_issuances_agent_id_agents_id_fk": {
          "name": "connection_token_issuances_agent_id_agents_id_fk",
          "tableFrom": "connection_token_issuances",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "connection_token_issuances_run_id_heartbeat_runs_id_fk": {
          "name": "connection_token_issuances_run_id_heartbeat_runs_id_fk",
          "tableFrom": "connection_token_issuances",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "connection_token_issuances_issue_id_issues_id_fk": {
          "name": "connection_token_issuances_issue_id_issues_id_fk",
          "tableFrom": "connection_token_issuances",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "connection_token_issuances_project_id_projects_id_fk": {
          "name": "connection_token_issuances_project_id_projects_id_fk",
          "tableFrom": "connection_token_issuances",
          "tableTo": "projects",
          "columnsFrom": [
            "project_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.instance_settings": {
      "name": "instance_settings",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "singleton_key": {
          "name": "singleton_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'default'"
        },
        "default_environment_id": {
          "name": "default_environment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "general": {
          "name": "general",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "experimental": {
          "name": "experimental",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": true,
          "default": "'{}'::jsonb"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "instance_settings_singleton_key_idx": {
          "name": "instance_settings_singleton_key_idx",
          "columns": [
            {
              "expression": "singleton_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "instance_settings_default_environment_id_environments_id_fk": {
          "name": "instance_settings_default_environment_id_environments_id_fk",
          "tableFrom": "instance_settings",
          "tableTo": "environments",
          "columnsFrom": [
            "default_environment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.instance_user_roles": {
      "name": "instance_user_roles",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "role": {
          "name": "role",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'instance_admin'"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "instance_user_roles_user_role_unique_idx": {
          "name": "instance_user_roles_user_role_unique_idx",
          "columns": [
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "role",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "instance_user_roles_role_idx": {
          "name": "instance_user_roles_role_idx",
          "columns": [
            {
              "expression": "role",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.invites": {
      "name": "invites",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "invite_type": {
          "name": "invite_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'company_join'"
        },
        "token_hash": {
          "name": "token_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "allowed_join_types": {
          "name": "allowed_join_types",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'both'"
        },
        "defaults_payload": {
          "name": "defaults_payload",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true
        },
        "invited_by_user_id": {
          "name": "invited_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "revoked_at": {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "accepted_at": {
          "name": "accepted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "invites_token_hash_unique_idx": {
          "name": "invites_token_hash_unique_idx",
          "columns": [
            {
              "expression": "token_hash",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "invites_company_invite_state_idx": {
          "name": "invites_company_invite_state_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "invite_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "revoked_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "expires_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "invites_company_id_companies_id_fk": {
          "name": "invites_company_id_companies_id_fk",
          "tableFrom": "invites",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.issue_access_grants": {
      "name": "issue_access_grants",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "subject_type": {
          "name": "subject_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "subject_id": {
          "name": "subject_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "source": {
          "name": "source",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "granted_by_user_id": {
          "name": "granted_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "granted_by_agent_id": {
          "name": "granted_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "revoked_at": {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {
        "issue_access_grants_subject_active_issue_idx": {
          "name": "issue_access_grants_subject_active_issue_idx",
          "columns": [
            {
              "expression": "subject_type",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "subject_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "revoked_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_access_grants_issue_idx": {
          "name": "issue_access_grants_issue_idx",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "issue_access_grants_issue_id_issues_id_fk": {
          "name": "issue_access_grants_issue_id_issues_id_fk",
          "tableFrom": "issue_access_grants",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "issue_access_grants_granted_by_agent_id_agents_id_fk": {
          "name": "issue_access_grants_granted_by_agent_id_agents_id_fk",
          "tableFrom": "issue_access_grants",
          "tableTo": "agents",
          "columnsFrom": [
            "granted_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {
        "issue_access_grants_subject_type_check": {
          "name": "issue_access_grants_subject_type_check",
          "value": "\"issue_access_grants\".\"subject_type\" in ('user', 'agent')"
        },
        "issue_access_grants_source_check": {
          "name": "issue_access_grants_source_check",
          "value": "\"issue_access_grants\".\"source\" in ('explicit', 'assignment', 'project')"
        }
      },
      "isRLSEnabled": false
    },
    "public.issue_approvals": {
      "name": "issue_approvals",
      "schema": "",
      "columns": {
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "approval_id": {
          "name": "approval_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "linked_by_agent_id": {
          "name": "linked_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "linked_by_user_id": {
          "name": "linked_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "issue_approvals_issue_idx": {
          "name": "issue_approvals_issue_idx",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_approvals_approval_idx": {
          "name": "issue_approvals_approval_idx",
          "columns": [
            {
              "expression": "approval_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_approvals_company_idx": {
          "name": "issue_approvals_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "issue_approvals_company_id_companies_id_fk": {
          "name": "issue_approvals_company_id_companies_id_fk",
          "tableFrom": "issue_approvals",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "issue_approvals_issue_id_issues_id_fk": {
          "name": "issue_approvals_issue_id_issues_id_fk",
          "tableFrom": "issue_approvals",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "issue_approvals_approval_id_approvals_id_fk": {
          "name": "issue_approvals_approval_id_approvals_id_fk",
          "tableFrom": "issue_approvals",
          "tableTo": "approvals",
          "columnsFrom": [
            "approval_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "issue_approvals_linked_by_agent_id_agents_id_fk": {
          "name": "issue_approvals_linked_by_agent_id_agents_id_fk",
          "tableFrom": "issue_approvals",
          "tableTo": "agents",
          "columnsFrom": [
            "linked_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {
        "issue_approvals_pk": {
          "name": "issue_approvals_pk",
          "columns": [
            "issue_id",
            "approval_id"
          ]
        }
      },
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.issue_attachments": {
      "name": "issue_attachments",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "asset_id": {
          "name": "asset_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_comment_id": {
          "name": "issue_comment_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "originating_run_id": {
          "name": "originating_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "issue_attachments_company_issue_idx": {
          "name": "issue_attachments_company_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_attachments_issue_comment_idx": {
          "name": "issue_attachments_issue_comment_idx",
          "columns": [
            {
              "expression": "issue_comment_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_attachments_originating_run_idx": {
          "name": "issue_attachments_originating_run_idx",
          "columns": [
            {
              "expression": "originating_run_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_attachments_asset_uq": {
          "name": "issue_attachments_asset_uq",
          "columns": [
            {
              "expression": "asset_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "issue_attachments_company_id_companies_id_fk": {
          "name": "issue_attachments_company_id_companies_id_fk",
          "tableFrom": "issue_attachments",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "issue_attachments_issue_id_issues_id_fk": {
          "name": "issue_attachments_issue_id_issues_id_fk",
          "tableFrom": "issue_attachments",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "issue_attachments_asset_id_assets_id_fk": {
          "name": "issue_attachments_asset_id_assets_id_fk",
          "tableFrom": "issue_attachments",
          "tableTo": "assets",
          "columnsFrom": [
            "asset_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "issue_attachments_issue_comment_id_issue_comments_id_fk": {
          "name": "issue_attachments_issue_comment_id_issue_comments_id_fk",
          "tableFrom": "issue_attachments",
          "tableTo": "issue_comments",
          "columnsFrom": [
            "issue_comment_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "issue_attachments_originating_run_id_heartbeat_runs_id_fk": {
          "name": "issue_attachments_originating_run_id_heartbeat_runs_id_fk",
          "tableFrom": "issue_attachments",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "originating_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.issue_comments": {
      "name": "issue_comments",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "author_agent_id": {
          "name": "author_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "author_user_id": {
          "name": "author_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "on_behalf_of_user_id": {
          "name": "on_behalf_of_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "author_type": {
          "name": "author_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_by_run_id": {
          "name": "created_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "derived_author_agent_id": {
          "name": "derived_author_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "derived_created_by_run_id": {
          "name": "derived_created_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "derived_author_source": {
          "name": "derived_author_source",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "client_request_id": {
          "name": "client_request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "conversation_session_generation": {
          "name": "conversation_session_generation",
          "type": "integer",
          "primaryKey": false,
          "notNull": false
        },
        "origin": {
          "name": "origin",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'comment'"
        },
        "fast_response_request_id": {
          "name": "fast_response_request_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "body": {
          "name": "body",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "presentation": {
          "name": "presentation",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "metadata": {
          "name": "metadata",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "deleted_at": {
          "name": "deleted_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": false
        },
        "deleted_by_type": {
          "name": "deleted_by_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "deleted_by_agent_id": {
          "name": "deleted_by_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "deleted_by_user_id": {
          "name": "deleted_by_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "deleted_by_run_id": {
          "name": "deleted_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "source_trust": {
          "name": "source_trust",
          "type": "jsonb",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "issue_comments_issue_idx": {
          "name": "issue_comments_issue_idx",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_comments_company_idx": {
          "name": "issue_comments_company_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_comments_company_issue_created_at_idx": {
          "name": "issue_comments_company_issue_created_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_comments_company_author_issue_created_at_idx": {
          "name": "issue_comments_company_author_issue_created_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "author_user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_comments_body_search_idx": {
          "name": "issue_comments_body_search_idx",
          "columns": [
            {
              "expression": "body",
              "isExpression": false,
              "asc": true,
              "nulls": "last",
              "opclass": "gin_trgm_ops"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "gin",
          "with": {}
        }
      },
      "foreignKeys": {
        "issue_comments_company_id_companies_id_fk": {
          "name": "issue_comments_company_id_companies_id_fk",
          "tableFrom": "issue_comments",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "issue_comments_issue_id_issues_id_fk": {
          "name": "issue_comments_issue_id_issues_id_fk",
          "tableFrom": "issue_comments",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "issue_comments_author_agent_id_agents_id_fk": {
          "name": "issue_comments_author_agent_id_agents_id_fk",
          "tableFrom": "issue_comments",
          "tableTo": "agents",
          "columnsFrom": [
            "author_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "issue_comments_on_behalf_of_user_id_user_id_fk": {
          "name": "issue_comments_on_behalf_of_user_id_user_id_fk",
          "tableFrom": "issue_comments",
          "tableTo": "user",
          "columnsFrom": [
            "on_behalf_of_user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "issue_comments_created_by_run_id_heartbeat_runs_id_fk": {
          "name": "issue_comments_created_by_run_id_heartbeat_runs_id_fk",
          "tableFrom": "issue_comments",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "created_by_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "issue_comments_derived_author_agent_id_agents_id_fk": {
          "name": "issue_comments_derived_author_agent_id_agents_id_fk",
          "tableFrom": "issue_comments",
          "tableTo": "agents",
          "columnsFrom": [
            "derived_author_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "issue_comments_derived_created_by_run_id_heartbeat_runs_id_fk": {
          "name": "issue_comments_derived_created_by_run_id_heartbeat_runs_id_fk",
          "tableFrom": "issue_comments",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "derived_created_by_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "issue_comments_deleted_by_agent_id_agents_id_fk": {
          "name": "issue_comments_deleted_by_agent_id_agents_id_fk",
          "tableFrom": "issue_comments",
          "tableTo": "agents",
          "columnsFrom": [
            "deleted_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "issue_comments_deleted_by_run_id_heartbeat_runs_id_fk": {
          "name": "issue_comments_deleted_by_run_id_heartbeat_runs_id_fk",
          "tableFrom": "issue_comments",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "deleted_by_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "issue_comments_client_request_uq": {
          "name": "issue_comments_client_request_uq",
          "nullsNotDistinct": false,
          "columns": [
            "issue_id",
            "author_user_id",
            "client_request_id"
          ]
        },
        "issue_comments_company_id_uq": {
          "name": "issue_comments_company_id_uq",
          "nullsNotDistinct": false,
          "columns": [
            "company_id",
            "id"
          ]
        }
      },
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.issue_create_idempotency_keys": {
      "name": "issue_create_idempotency_keys",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "issue_create_idempotency_keys_company_key_uq": {
          "name": "issue_create_idempotency_keys_company_key_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "idempotency_key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_create_idempotency_keys_issue_idx": {
          "name": "issue_create_idempotency_keys_issue_idx",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_create_idempotency_keys_company_created_at_idx": {
          "name": "issue_create_idempotency_keys_company_created_at_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "issue_create_idempotency_keys_company_id_companies_id_fk": {
          "name": "issue_create_idempotency_keys_company_id_companies_id_fk",
          "tableFrom": "issue_create_idempotency_keys",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "issue_create_idempotency_keys_issue_id_issues_id_fk": {
          "name": "issue_create_idempotency_keys_issue_id_issues_id_fk",
          "tableFrom": "issue_create_idempotency_keys",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.issue_documents": {
      "name": "issue_documents",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "document_id": {
          "name": "document_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "issue_documents_company_issue_key_uq": {
          "name": "issue_documents_company_issue_key_uq",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "key",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_documents_document_uq": {
          "name": "issue_documents_document_uq",
          "columns": [
            {
              "expression": "document_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_documents_company_issue_updated_idx": {
          "name": "issue_documents_company_issue_updated_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "updated_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "issue_documents_company_id_companies_id_fk": {
          "name": "issue_documents_company_id_companies_id_fk",
          "tableFrom": "issue_documents",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "issue_documents_issue_id_issues_id_fk": {
          "name": "issue_documents_issue_id_issues_id_fk",
          "tableFrom": "issue_documents",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "issue_documents_document_id_documents_id_fk": {
          "name": "issue_documents_document_id_documents_id_fk",
          "tableFrom": "issue_documents",
          "tableTo": "documents",
          "columnsFrom": [
            "document_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.issue_execution_decisions": {
      "name": "issue_execution_decisions",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "stage_id": {
          "name": "stage_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "stage_type": {
          "name": "stage_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "actor_agent_id": {
          "name": "actor_agent_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "actor_user_id": {
          "name": "actor_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "outcome": {
          "name": "outcome",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "body": {
          "name": "body",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_by_run_id": {
          "name": "created_by_run_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "issue_execution_decisions_company_issue_idx": {
          "name": "issue_execution_decisions_company_issue_idx",
          "columns": [
            {
              "expression": "company_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "issue_execution_decisions_stage_idx": {
          "name": "issue_execution_decisions_stage_idx",
          "columns": [
            {
              "expression": "issue_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "stage_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "created_at",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "issue_execution_decisions_company_id_companies_id_fk": {
          "name": "issue_execution_decisions_company_id_companies_id_fk",
          "tableFrom": "issue_execution_decisions",
          "tableTo": "companies",
          "columnsFrom": [
            "company_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "issue_execution_decisions_issue_id_issues_id_fk": {
          "name": "issue_execution_decisions_issue_id_issues_id_fk",
          "tableFrom": "issue_execution_decisions",
          "tableTo": "issues",
          "columnsFrom": [
            "issue_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "issue_execution_decisions_actor_agent_id_agents_id_fk": {
          "name": "issue_execution_decisions_actor_agent_id_agents_id_fk",
          "tableFrom": "issue_execution_decisions",
          "tableTo": "agents",
          "columnsFrom": [
            "actor_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "issue_execution_decisions_created_by_run_id_heartbeat_runs_id_fk": {
          "name": "issue_execution_decisions_created_by_run_id_heartbeat_runs_id_fk",
          "tableFrom": "issue_execution_decisions",
          "tableTo": "heartbeat_runs",
          "columnsFrom": [
            "created_by_run_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.issue_inbox_archives": {
      "name": "issue_inbox_archives",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "company_id": {
          "name": "company_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "issue_id": {
          "name": "issue_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "archived_by_actor_type": {
          "name": "archived_by_actor_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'user'"
        },
        "archived_by_agent_id": {
          "name": "archived_by_agent_id",
       

File truncated at 1 MB.