Seed development data from the database command (task 47) #22
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/seed-data"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
dotnet run --project src/PlaceMark.Database -- seed— 3 users with personal groups, one shared group covering every role and both invitation statuses, 8 places spanning both hemispheres, the prime meridian, the equator and longitude 180. Idempotent viaON CONFLICT ON CONSTRAINT … DO NOTHINGin one transaction. Recorded in ADR-0026.Two independent production guards: the seed reads its own
ConnectionStrings__PlaceMarkSeedTarget, never the variable ADR-0023 expects to be exported when applying schema to production; and it refuses any database holding accounts it did not create. An empty production database is protected by the variable alone — stated in the ADR.Seed SQL lives in C# constants, not a
.sqlfile: DbUp is handed the whole assembly, so a seed script underScripts/would be journalled and deployed to production.Needs a decision:
password_hashisNULLand noexternal_identitiesrow exists, because nothing hashes passwords yet. Whichever auth ticket adds hashing must supplySeedDataa real value.docker compose down -vor a second database.Program.csin the Database project gained a three-line dispatch; no arguments still means schema upgrade, so CI and ADR-0023 are unaffected. That dispatch is the one line no test covers.Incidental, relevant to the Dapper work ahead: Dapper sends a collection to PostgreSQL as a single array parameter rather than expanding it, so
IN @Idsfails with42601— use= ANY(@Ids).DatabaseSeeder.GuardAsynccounts accounts at READ COMMITTED, so a registration that commits between that count and the seed'sCOMMITis invisible to it — against a fresh schema-only database the seed exits 0 and writes its three demo users beside a real account. Either takeLOCK TABLE users IN SHARE MODEinside the transaction before the count (checked: the seed then waits and refuses, writing nothing), or record the limit in ADR-0026's Consequences beside the empty-database one; as written, both the record and the PR body claim a refusal that does not hold while anything else is writing tousers.RunAsync_SeedApplied_CreatesPlacesInEveryQuadrantOfTheGlobeasserts that each axis crosses zero, not that the four quadrants are occupied — flipping Ny-Ålesund to longitude-11.9231empties the north-eastern quadrant and the test still passes. Assert the quadrants, and pin longitude exactly180, which is the boundary value ADR-0026 calls the point of that row and which nothing currently fails on if it is edited.Every seeded user breaks
docs/data-model.mdinvariant 5 ("a user should hold at least one usable credential"); the seed paragraph added to that document warns that seeded rows are the first thing that can break an unenforced invariant without saying that one already is. Add the pointer at invariant 5 itself, where an implementer will read it.dotnet run --project src/PlaceMark.Database -- seed --forceprintsUnknown command 'seed'. Name the actual fault (unexpected arguments) rather than the command that was recognised.Verdict: changes required
All four actioned in
25749ad, plus the two you noted but did not raise: theux_groups_personal_for_user_idfailure mode is recorded in ADR-0026 rather than papered over, and the seeded identifiers are now pinned by a test.Nothing to act on: all four findings are addressed, the lock-mode reasoning holds under test, and each new assertion fails when the thing it defends is edited.
Verdict: mergeable
rob referenced this pull request2026-08-03 14:08:57 +00:00