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:
mika kuns
2026-08-11 10:49:06 +02:00
parent 31a9e87b56
commit 9e46c96b24
25 changed files with 1416 additions and 50 deletions
@@ -74,9 +74,9 @@ public sealed class TreeMergeTests : IDisposable
using (var ctx = db.CreateContext())
{
ctx.Lists.Add(new ListEntity { Id = listId, Name = "L", WorkingDir = repo.RepoDir, CreatedAt = DateTime.UtcNow });
ctx.Tasks.Add(new TaskEntity { Id = parentId, ListId = listId, Title = "Parent",
ctx.Tasks.Add(new TaskEntity { Id = parentId, ListId = listId, Title = "Parent", Number = 1,
Status = TaskStatus.WaitingForReview, PlanningPhase = PlanningPhase.None, SortOrder = 0, CreatedAt = DateTime.UtcNow });
ctx.Tasks.Add(new TaskEntity { Id = childId, ListId = listId, Title = "Child",
ctx.Tasks.Add(new TaskEntity { Id = childId, ListId = listId, Title = "Child", Number = 2,
Status = TaskStatus.Done, ParentTaskId = parentId, SortOrder = 1, CreatedAt = DateTime.UtcNow });
await ctx.SaveChangesAsync();