build(016-load-concurrency-testing): T001-T002 setup + concurrency-guard migration
Adds autocannon as a devDependency for the load-test tooling (T001), and the shared schema migration T002 blocks: SLARun.version for optimistic concurrency, plus two Postgres partial unique indexes (assignments_one_current_per_ticket, escalation_events_ticket_rule_unique) guarding against the assignment and escalation races research.md documents. Applied directly to both the real dev DB and the throwaway test DB. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
2fb5b7ac73
commit
1e332143bd
@@ -0,0 +1,13 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "sla_runs" ADD COLUMN "version" INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
-- 016-load-concurrency-testing research.md §1: at most one current assignment per ticket,
|
||||
-- enforced at the database level (a partial unique index, since Prisma's schema DSL cannot
|
||||
-- express a WHERE-predicated unique constraint directly).
|
||||
CREATE UNIQUE INDEX "assignments_one_current_per_ticket" ON "assignments"("ticketId") WHERE "isCurrent" = true;
|
||||
|
||||
-- 016-load-concurrency-testing research.md §3: a given escalation rule may fire at most once
|
||||
-- per ticket over that ticket's lifetime (SLARun.ticketId is already @unique — no reopen-cycle
|
||||
-- support, so a rule-triggered breach genuinely cannot recur for the same ticket). Manual
|
||||
-- escalations (rule_id IS NULL) are excluded and remain repeatable.
|
||||
CREATE UNIQUE INDEX "escalation_events_ticket_rule_unique" ON "escalation_events"("ticketId", "ruleId") WHERE "ruleId" IS NOT NULL;
|
||||
@@ -595,6 +595,11 @@ model SLARun {
|
||||
|
||||
completedAt DateTime?
|
||||
|
||||
// 016-load-concurrency-testing: optimistic-concurrency counter, identical convention to
|
||||
// Ticket.version (003-ticketing) — guards pause/resume/complete/the breach sweep against
|
||||
// racing each other and silently clobbering this run's state (research.md §2).
|
||||
version Int @default(0)
|
||||
|
||||
@@index([status, resolutionDueAt])
|
||||
@@index([status, firstResponseDueAt])
|
||||
@@map("sla_runs")
|
||||
|
||||
Reference in New Issue
Block a user