using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace ClaudeDo.Data.Migrations { /// public partial class UniqueListName : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { // Remove duplicate list rows that have no tasks — keep the oldest rowid. // This handles the startup-race case where both App and Worker seeded // the same default list names concurrently. migrationBuilder.Sql(""" DELETE FROM lists WHERE (SELECT COUNT(*) FROM tasks WHERE list_id = lists.id) = 0 AND rowid NOT IN ( SELECT MIN(l2.rowid) FROM lists l2 WHERE l2.name = lists.name ) """); } /// protected override void Down(MigrationBuilder migrationBuilder) { } } }