using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional namespace ClaudeDo.Data.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "lists", columns: table => new { id = table.Column(type: "TEXT", nullable: false), name = table.Column(type: "TEXT", nullable: false), created_at = table.Column(type: "TEXT", nullable: false), working_dir = table.Column(type: "TEXT", nullable: true), default_commit_type = table.Column(type: "TEXT", nullable: false, defaultValue: "chore") }, constraints: table => { table.PrimaryKey("PK_lists", x => x.id); }); migrationBuilder.CreateTable( name: "tags", columns: table => new { id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), name = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_tags", x => x.id); }); migrationBuilder.CreateTable( name: "list_config", columns: table => new { list_id = table.Column(type: "TEXT", nullable: false), model = table.Column(type: "TEXT", nullable: true), system_prompt = table.Column(type: "TEXT", nullable: true), agent_path = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_list_config", x => x.list_id); table.ForeignKey( name: "FK_list_config_lists_list_id", column: x => x.list_id, principalTable: "lists", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "tasks", columns: table => new { id = table.Column(type: "TEXT", nullable: false), list_id = table.Column(type: "TEXT", nullable: false), title = table.Column(type: "TEXT", nullable: false), description = table.Column(type: "TEXT", nullable: true), status = table.Column(type: "TEXT", nullable: false), scheduled_for = table.Column(type: "TEXT", nullable: true), result = table.Column(type: "TEXT", nullable: true), log_path = table.Column(type: "TEXT", nullable: true), created_at = table.Column(type: "TEXT", nullable: false), started_at = table.Column(type: "TEXT", nullable: true), finished_at = table.Column(type: "TEXT", nullable: true), commit_type = table.Column(type: "TEXT", nullable: false, defaultValue: "chore"), model = table.Column(type: "TEXT", nullable: true), system_prompt = table.Column(type: "TEXT", nullable: true), agent_path = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_tasks", x => x.id); table.ForeignKey( name: "FK_tasks_lists_list_id", column: x => x.list_id, principalTable: "lists", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "list_tags", columns: table => new { list_id = table.Column(type: "TEXT", nullable: false), tag_id = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_list_tags", x => new { x.list_id, x.tag_id }); table.ForeignKey( name: "FK_list_tags_lists_list_id", column: x => x.list_id, principalTable: "lists", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_list_tags_tags_tag_id", column: x => x.tag_id, principalTable: "tags", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "subtasks", columns: table => new { id = table.Column(type: "TEXT", nullable: false), task_id = table.Column(type: "TEXT", nullable: false), title = table.Column(type: "TEXT", nullable: false), completed = table.Column(type: "INTEGER", nullable: false, defaultValue: false), order_num = table.Column(type: "INTEGER", nullable: false), created_at = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_subtasks", x => x.id); table.ForeignKey( name: "FK_subtasks_tasks_task_id", column: x => x.task_id, principalTable: "tasks", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "task_runs", columns: table => new { id = table.Column(type: "TEXT", nullable: false), task_id = table.Column(type: "TEXT", nullable: false), run_number = table.Column(type: "INTEGER", nullable: false), session_id = table.Column(type: "TEXT", nullable: true), is_retry = table.Column(type: "INTEGER", nullable: false, defaultValue: false), prompt = table.Column(type: "TEXT", nullable: false), result_markdown = table.Column(type: "TEXT", nullable: true), structured_output = table.Column(type: "TEXT", nullable: true), error_markdown = table.Column(type: "TEXT", nullable: true), exit_code = table.Column(type: "INTEGER", nullable: true), turn_count = table.Column(type: "INTEGER", nullable: true), tokens_in = table.Column(type: "INTEGER", nullable: true), tokens_out = table.Column(type: "INTEGER", nullable: true), log_path = table.Column(type: "TEXT", nullable: true), started_at = table.Column(type: "TEXT", nullable: true), finished_at = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_task_runs", x => x.id); table.ForeignKey( name: "FK_task_runs_tasks_task_id", column: x => x.task_id, principalTable: "tasks", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "task_tags", columns: table => new { task_id = table.Column(type: "TEXT", nullable: false), tag_id = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_task_tags", x => new { x.task_id, x.tag_id }); table.ForeignKey( name: "FK_task_tags_tags_tag_id", column: x => x.tag_id, principalTable: "tags", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_task_tags_tasks_task_id", column: x => x.task_id, principalTable: "tasks", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "worktrees", columns: table => new { task_id = table.Column(type: "TEXT", nullable: false), path = table.Column(type: "TEXT", nullable: false), branch_name = table.Column(type: "TEXT", nullable: false), base_commit = table.Column(type: "TEXT", nullable: false), head_commit = table.Column(type: "TEXT", nullable: true), diff_stat = table.Column(type: "TEXT", nullable: true), state = table.Column(type: "TEXT", nullable: false, defaultValue: "active"), created_at = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_worktrees", x => x.task_id); table.ForeignKey( name: "FK_worktrees_tasks_task_id", column: x => x.task_id, principalTable: "tasks", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( table: "tags", columns: new[] { "id", "name" }, values: new object[,] { { 1L, "agent" }, { 2L, "manual" } }); migrationBuilder.CreateIndex( name: "IX_list_tags_tag_id", table: "list_tags", column: "tag_id"); migrationBuilder.CreateIndex( name: "idx_subtasks_task_id", table: "subtasks", column: "task_id"); migrationBuilder.CreateIndex( name: "IX_tags_name", table: "tags", column: "name", unique: true); migrationBuilder.CreateIndex( name: "idx_task_runs_task_id", table: "task_runs", column: "task_id"); migrationBuilder.CreateIndex( name: "IX_task_tags_tag_id", table: "task_tags", column: "tag_id"); migrationBuilder.CreateIndex( name: "idx_tasks_list_id", table: "tasks", column: "list_id"); migrationBuilder.CreateIndex( name: "idx_tasks_status", table: "tasks", column: "status"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "list_config"); migrationBuilder.DropTable( name: "list_tags"); migrationBuilder.DropTable( name: "subtasks"); migrationBuilder.DropTable( name: "task_runs"); migrationBuilder.DropTable( name: "task_tags"); migrationBuilder.DropTable( name: "worktrees"); migrationBuilder.DropTable( name: "tags"); migrationBuilder.DropTable( name: "tasks"); migrationBuilder.DropTable( name: "lists"); } } }