{
  "version": "7",
  "dialect": "sqlite",
  "id": "ceb18d57-08e2-4b6d-a4e7-c098acfa181a",
  "prevIds": ["00000000-0000-0000-0000-000000000000"],
  "ddl": [
    {
      "name": "projects",
      "entityType": "tables"
    },
    {
      "name": "remote_state",
      "entityType": "tables"
    },
    {
      "name": "threads",
      "entityType": "tables"
    },
    {
      "name": "writer_leases",
      "entityType": "tables"
    },
    {
      "type": "integer",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "created_at",
      "entityType": "columns",
      "table": "projects"
    },
    {
      "type": "text",
      "notNull": false,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "id",
      "entityType": "columns",
      "table": "projects"
    },
    {
      "type": "text",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "metadata",
      "entityType": "columns",
      "table": "projects"
    },
    {
      "type": "text",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "name",
      "entityType": "columns",
      "table": "projects"
    },
    {
      "type": "integer",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "position",
      "entityType": "columns",
      "table": "projects"
    },
    {
      "type": "text",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "roots",
      "entityType": "columns",
      "table": "projects"
    },
    {
      "type": "integer",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "updated_at",
      "entityType": "columns",
      "table": "projects"
    },
    {
      "type": "text",
      "notNull": false,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "key",
      "entityType": "columns",
      "table": "remote_state"
    },
    {
      "type": "integer",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "updated_at",
      "entityType": "columns",
      "table": "remote_state"
    },
    {
      "type": "text",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "value",
      "entityType": "columns",
      "table": "remote_state"
    },
    {
      "type": "integer",
      "notNull": true,
      "autoincrement": false,
      "default": "false",
      "generated": null,
      "name": "archived",
      "entityType": "columns",
      "table": "threads"
    },
    {
      "type": "text",
      "notNull": false,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "project_id",
      "entityType": "columns",
      "table": "threads"
    },
    {
      "type": "text",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "session_file",
      "entityType": "columns",
      "table": "threads"
    },
    {
      "type": "text",
      "notNull": false,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "id",
      "entityType": "columns",
      "table": "threads"
    },
    {
      "type": "integer",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "updated_at",
      "entityType": "columns",
      "table": "threads"
    },
    {
      "type": "integer",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "expires_at_ms",
      "entityType": "columns",
      "table": "writer_leases"
    },
    {
      "type": "integer",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "fence",
      "entityType": "columns",
      "table": "writer_leases"
    },
    {
      "type": "text",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "owner_id",
      "entityType": "columns",
      "table": "writer_leases"
    },
    {
      "type": "text",
      "notNull": true,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "owner_kind",
      "entityType": "columns",
      "table": "writer_leases"
    },
    {
      "type": "text",
      "notNull": false,
      "autoincrement": false,
      "default": null,
      "generated": null,
      "name": "thread_id",
      "entityType": "columns",
      "table": "writer_leases"
    },
    {
      "columns": ["project_id"],
      "tableTo": "projects",
      "columnsTo": ["id"],
      "onUpdate": "NO ACTION",
      "onDelete": "SET NULL",
      "nameExplicit": false,
      "name": "fk_threads_project_id_projects_id_fk",
      "entityType": "fks",
      "table": "threads"
    },
    {
      "columns": ["id"],
      "nameExplicit": false,
      "name": "projects_pk",
      "table": "projects",
      "entityType": "pks"
    },
    {
      "columns": ["key"],
      "nameExplicit": false,
      "name": "remote_state_pk",
      "table": "remote_state",
      "entityType": "pks"
    },
    {
      "columns": ["id"],
      "nameExplicit": false,
      "name": "threads_pk",
      "table": "threads",
      "entityType": "pks"
    },
    {
      "columns": ["thread_id"],
      "nameExplicit": false,
      "name": "writer_leases_pk",
      "table": "writer_leases",
      "entityType": "pks"
    },
    {
      "columns": [
        {
          "value": "position",
          "isExpression": false
        },
        {
          "value": "created_at",
          "isExpression": false
        }
      ],
      "isUnique": false,
      "where": null,
      "origin": "manual",
      "name": "projects_order_idx",
      "entityType": "indexes",
      "table": "projects"
    },
    {
      "columns": [
        {
          "value": "updated_at",
          "isExpression": false
        }
      ],
      "isUnique": false,
      "where": null,
      "origin": "manual",
      "name": "threads_updated_at_idx",
      "entityType": "indexes",
      "table": "threads"
    },
    {
      "columns": ["session_file"],
      "nameExplicit": false,
      "name": "threads_session_file_unique",
      "entityType": "uniques",
      "table": "threads"
    },
    {
      "value": "\"owner_kind\" in ('daemon', 'tui')",
      "name": "writer_leases_owner_kind_check",
      "entityType": "checks",
      "table": "writer_leases"
    }
  ],
  "renames": []
}
