feat(data): add task numbers schema, allocator, and backfill migration
TaskEntity.Number is a global, monotonically increasing, never-reused integer (displayed as #123), allocated from AppSettingsEntity.NextTaskNumber via a single UPDATE...RETURNING statement rather than MAX(number)+1, which would reissue a deleted task's number. Both insert paths (TaskRepository. AddAsync and CreateChildAsync) route through the new TaskNumberAllocator, with a bounded retry on a unique-index collision. One migration adds the columns, backfills existing rows in creation order, and creates the unique index afterwards. Data-layer only; MCP/UI wiring is later slices.
This commit is contained in:
@@ -12,6 +12,7 @@ namespace ClaudeDo.Worker.Tests;
|
||||
public sealed class SuggestImprovementTests : IDisposable
|
||||
{
|
||||
private readonly DbFixture _db = new();
|
||||
private int _numberSeed;
|
||||
public void Dispose() => _db.Dispose();
|
||||
|
||||
private static TaskRunMcpContextAccessor AccessorFor(string callerTaskId)
|
||||
@@ -26,7 +27,7 @@ public sealed class SuggestImprovementTests : IDisposable
|
||||
using var ctx = _db.CreateContext();
|
||||
if (!ctx.Lists.Any())
|
||||
ctx.Lists.Add(new ListEntity { Id = "l1", Name = "L", CreatedAt = DateTime.UtcNow });
|
||||
ctx.Tasks.Add(new TaskEntity { Id = id, ListId = "l1", Title = "Caller",
|
||||
ctx.Tasks.Add(new TaskEntity { Id = id, ListId = "l1", Title = "Caller", Number = ++_numberSeed,
|
||||
Status = TaskStatus.Running, ParentTaskId = parentId, CommitType = "feat", CreatedAt = DateTime.UtcNow });
|
||||
await ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user