// This file is generated by src/actors/_scripts/generate-actor-migrations.ts.
// Source of truth is drizzle-kit output under ./drizzle (meta/_journal.json + *.sql).
// Do not hand-edit this file.

const journal = {
  entries: [
    {
      idx: 0,
      when: 1770924374665,
      tag: "0000_condemned_maria_hill",
      breakpoints: true,
    },
    {
      idx: 1,
      when: 1770947251055,
      tag: "0001_rapid_eddie_brock",
      breakpoints: true,
    },
    {
      idx: 2,
      when: 1770948428907,
      tag: "0002_lazy_moira_mactaggert",
      breakpoints: true,
    },
    {
      idx: 3,
      when: 1771027535276,
      tag: "0003_plucky_bran",
      breakpoints: true,
    },
    {
      idx: 4,
      when: 1771097651912,
      tag: "0004_focused_shuri",
      breakpoints: true,
    },
    {
      idx: 5,
      when: 1771370000000,
      tag: "0005_sandbox_actor_id",
      breakpoints: true,
    },
    {
      idx: 6,
      when: 1773020000000,
      tag: "0006_workbench_sessions",
      breakpoints: true,
    },
  ],
} as const;

export default {
  journal,
  migrations: {
    m0000: `CREATE TABLE \`handoff\` (
	\`id\` integer PRIMARY KEY NOT NULL,
	\`branch_name\` text NOT NULL,
	\`title\` text NOT NULL,
	\`task\` text NOT NULL,
	\`provider_id\` text NOT NULL,
	\`status\` text NOT NULL,
	\`agent_type\` text DEFAULT 'claude',
	\`auto_committed\` integer DEFAULT 0,
	\`pushed\` integer DEFAULT 0,
	\`pr_submitted\` integer DEFAULT 0,
	\`needs_push\` integer DEFAULT 0,
	\`created_at\` integer NOT NULL,
	\`updated_at\` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE \`handoff_runtime\` (
	\`id\` integer PRIMARY KEY NOT NULL,
	\`sandbox_id\` text,
	\`session_id\` text,
	\`switch_target\` text,
	\`status_message\` text,
	\`updated_at\` integer NOT NULL
);
`,
    m0001: `ALTER TABLE \`handoff\` DROP COLUMN \`auto_committed\`;--> statement-breakpoint
ALTER TABLE \`handoff\` DROP COLUMN \`pushed\`;--> statement-breakpoint
ALTER TABLE \`handoff\` DROP COLUMN \`needs_push\`;`,
    m0002: `ALTER TABLE \`handoff_runtime\` RENAME COLUMN "sandbox_id" TO "active_sandbox_id";--> statement-breakpoint
ALTER TABLE \`handoff_runtime\` RENAME COLUMN "session_id" TO "active_session_id";--> statement-breakpoint
ALTER TABLE \`handoff_runtime\` RENAME COLUMN "switch_target" TO "active_switch_target";--> statement-breakpoint
CREATE TABLE \`handoff_sandboxes\` (
	\`sandbox_id\` text PRIMARY KEY NOT NULL,
	\`provider_id\` text NOT NULL,
	\`switch_target\` text NOT NULL,
	\`cwd\` text,
	\`status_message\` text,
	\`created_at\` integer NOT NULL,
	\`updated_at\` integer NOT NULL
);
--> statement-breakpoint
ALTER TABLE \`handoff_runtime\` ADD \`active_cwd\` text;
--> statement-breakpoint
INSERT INTO \`handoff_sandboxes\` (
  \`sandbox_id\`,
  \`provider_id\`,
  \`switch_target\`,
  \`cwd\`,
  \`status_message\`,
  \`created_at\`,
  \`updated_at\`
)
SELECT
  r.\`active_sandbox_id\`,
  (SELECT h.\`provider_id\` FROM \`handoff\` h WHERE h.\`id\` = 1),
  r.\`active_switch_target\`,
  r.\`active_cwd\`,
  r.\`status_message\`,
  COALESCE((SELECT h.\`created_at\` FROM \`handoff\` h WHERE h.\`id\` = 1), r.\`updated_at\`),
  r.\`updated_at\`
FROM \`handoff_runtime\` r
WHERE
  r.\`id\` = 1
  AND r.\`active_sandbox_id\` IS NOT NULL
  AND r.\`active_switch_target\` IS NOT NULL
ON CONFLICT(\`sandbox_id\`) DO NOTHING;
`,
    m0003: `-- Allow handoffs to exist before their branch/title are determined.
-- Drizzle doesn't support altering column nullability in SQLite directly, so rebuild the table.

PRAGMA foreign_keys=off;

CREATE TABLE \`handoff__new\` (
	\`id\` integer PRIMARY KEY NOT NULL,
	\`branch_name\` text,
	\`title\` text,
	\`task\` text NOT NULL,
	\`provider_id\` text NOT NULL,
	\`status\` text NOT NULL,
	\`agent_type\` text DEFAULT 'claude',
	\`pr_submitted\` integer DEFAULT 0,
	\`created_at\` integer NOT NULL,
	\`updated_at\` integer NOT NULL
);

INSERT INTO \`handoff__new\` (
  \`id\`,
  \`branch_name\`,
  \`title\`,
  \`task\`,
  \`provider_id\`,
  \`status\`,
  \`agent_type\`,
  \`pr_submitted\`,
  \`created_at\`,
  \`updated_at\`
)
SELECT
  \`id\`,
  \`branch_name\`,
  \`title\`,
  \`task\`,
  \`provider_id\`,
  \`status\`,
  \`agent_type\`,
  \`pr_submitted\`,
  \`created_at\`,
  \`updated_at\`
FROM \`handoff\`;

DROP TABLE \`handoff\`;
ALTER TABLE \`handoff__new\` RENAME TO \`handoff\`;

PRAGMA foreign_keys=on;

`,
    m0004: `-- Fix: make branch_name/title nullable during initial "naming" stage.
-- 0003 was missing statement breakpoints, so drizzle's migrator marked it applied without executing all statements.
-- Rebuild the table again with proper statement breakpoints.

PRAGMA foreign_keys=off;
--> statement-breakpoint

DROP TABLE IF EXISTS \`handoff__new\`;
--> statement-breakpoint

CREATE TABLE \`handoff__new\` (
  \`id\` integer PRIMARY KEY NOT NULL,
  \`branch_name\` text,
  \`title\` text,
  \`task\` text NOT NULL,
  \`provider_id\` text NOT NULL,
  \`status\` text NOT NULL,
  \`agent_type\` text DEFAULT 'claude',
  \`pr_submitted\` integer DEFAULT 0,
  \`created_at\` integer NOT NULL,
  \`updated_at\` integer NOT NULL
);
--> statement-breakpoint

INSERT INTO \`handoff__new\` (
  \`id\`,
  \`branch_name\`,
  \`title\`,
  \`task\`,
  \`provider_id\`,
  \`status\`,
  \`agent_type\`,
  \`pr_submitted\`,
  \`created_at\`,
  \`updated_at\`
)
SELECT
  \`id\`,
  \`branch_name\`,
  \`title\`,
  \`task\`,
  \`provider_id\`,
  \`status\`,
  \`agent_type\`,
  \`pr_submitted\`,
  \`created_at\`,
  \`updated_at\`
FROM \`handoff\`;
--> statement-breakpoint

DROP TABLE \`handoff\`;
--> statement-breakpoint

ALTER TABLE \`handoff__new\` RENAME TO \`handoff\`;
--> statement-breakpoint

PRAGMA foreign_keys=on;
`,
    m0005: `ALTER TABLE \`handoff_sandboxes\` ADD \`sandbox_actor_id\` text;`,
    m0006: `CREATE TABLE \`handoff_workbench_sessions\` (
	\`session_id\` text PRIMARY KEY NOT NULL,
	\`session_name\` text NOT NULL,
	\`model\` text NOT NULL,
	\`unread\` integer DEFAULT 0 NOT NULL,
	\`draft_text\` text DEFAULT '' NOT NULL,
	\`draft_attachments_json\` text DEFAULT '[]' NOT NULL,
	\`draft_updated_at\` integer,
	\`created\` integer DEFAULT 1 NOT NULL,
	\`closed\` integer DEFAULT 0 NOT NULL,
	\`thinking_since_ms\` integer,
	\`created_at\` integer NOT NULL,
	\`updated_at\` integer NOT NULL
);`,
  } as const,
};
