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:
@@ -348,6 +348,7 @@ public class TasksIslandViewModelPlanningTests
|
||||
public sealed class TasksIslandViewModelMyDayTests : IDisposable
|
||||
{
|
||||
private readonly DbFixture _db = new();
|
||||
private int _numberSeed;
|
||||
public void Dispose() => _db.Dispose();
|
||||
|
||||
[Fact]
|
||||
@@ -361,6 +362,7 @@ public sealed class TasksIslandViewModelMyDayTests : IDisposable
|
||||
ctx.Tasks.Add(new TaskEntity
|
||||
{
|
||||
Id = taskId, ListId = listId, Title = "T", CreatedAt = DateTime.UtcNow,
|
||||
Number = ++_numberSeed,
|
||||
Status = TaskStatus.Idle, IsMyDay = false,
|
||||
});
|
||||
await ctx.SaveChangesAsync();
|
||||
@@ -391,16 +393,19 @@ public sealed class TasksIslandViewModelMyDayTests : IDisposable
|
||||
ctx.Tasks.Add(new TaskEntity
|
||||
{
|
||||
Id = parentId, ListId = listId, Title = "P", CreatedAt = DateTime.UtcNow,
|
||||
Number = ++_numberSeed,
|
||||
Status = TaskStatus.WaitingForChildren, PlanningPhase = PlanningPhase.Finalized, IsMyDay = true,
|
||||
});
|
||||
ctx.Tasks.Add(new TaskEntity
|
||||
{
|
||||
Id = child1, ListId = listId, Title = "C1", CreatedAt = DateTime.UtcNow,
|
||||
Number = ++_numberSeed,
|
||||
Status = TaskStatus.Idle, ParentTaskId = parentId, IsMyDay = true,
|
||||
});
|
||||
ctx.Tasks.Add(new TaskEntity
|
||||
{
|
||||
Id = child2, ListId = listId, Title = "C2", CreatedAt = DateTime.UtcNow,
|
||||
Number = ++_numberSeed,
|
||||
Status = TaskStatus.Idle, ParentTaskId = parentId, IsMyDay = true,
|
||||
});
|
||||
await ctx.SaveChangesAsync();
|
||||
|
||||
Reference in New Issue
Block a user