The startup-race hardening added a global unique index on lists.name, but duplicate list names are legitimate and the index broke 8 Worker tests that seed same-named lists. The seeder race is already handled by the atomic INSERT...WHERE NOT EXISTS, so the index is redundant. Keep the de-dup migration step, remove the unique index from config, migration and model snapshot. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31 lines
973 B
C#
31 lines
973 B
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace ClaudeDo.Data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class UniqueListName : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
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
|
|
)
|
|
""");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
}
|
|
}
|
|
}
|