Repository navigation
F12: Demo seed data — Seed:Demo flag (#58) - #63
Merged
Merged
Conversation
added 2 commits
July 17, 2026 17:28
A dev-DB wipe left every screen empty until data was re-clicked by hand. With Seed__Demo=true (default false — prod can never accidentally get fake data) a fresh database boots with: - Three flocks: 45wk + 20wk active layers and a depleted 2025 batch (backdated depletion via the domain so historical rules hold). - A week of submitted daily entries per active flock with graded production, losses, and sprinkled mortality — today left as a Draft for one flock and unrecorded for the other, so both entry states and the dashboard "no entry" flag show. - A 430-bird end-of-lay cull on the depleted flock. - Three customers; one confirmed order (FIFO allocation exercised) and one open draft. DemoDataSeeder runs in its own startup scope, resolves the TenantContext to the seeded account, and drives the real handlers — lots, stock, movements, and allocation exist exactly as if clicked in. Gated on an empty flock catalog: runs once on a fresh DB, no-op afterwards, never resurrects deleted data. Best-effort like the main seeder (failure logs and continues). Deterministic quantities (no Random) so demos are reproducible. Test (+1 -> 124): derived host with Seed:Demo + runtime-generated credentials on a fresh catalog — every read surface populated (3 flocks incl. depleted with ledger-reduced counts, stock > 0, confirmed + draft orders, 14+ entries); second startup is a no-op. Guard also verified against the populated dev DB: "Demo seed skipped: flocks already exist." Closes #58
- Seed:Enabled=false now disables the demo seed too — it is documented as switching off ALL startup seeding, and the demo seeder previously ignored it. (codex P2) - Partial-failure cleanup: the handlers commit step by step (ConfirmSale even opens its own transaction, so one outer transaction can't wrap the seed). A mid-seed failure now deletes the account's rows in the demo-touched tables — safe because the empty-flock guard guarantees everything there came from the failed run — so the next startup retries instead of being stuck half-seeded forever. (codex P2) Deferred: test residue on the shared default account (tenant filters isolate today's tests; revisit if any test ever asserts on the default account), delete-all-flocks-triggers-reseed (dev-only flag; a wipe is the intended reseed path). 124 tests green.
Owner
Author
Review round: codex + pi
124 tests green after fixes. |
pi review of the fix commit: cleanup's eight deletes were each their own autocommit — a mid-cleanup failure could leave a half-purged, silently inconsistent state. One transaction makes cleanup all-or-nothing. Comment no longer claims the flock guard proves more than it does (customers/orders are covered because DatabaseSeeder never writes them, not by the guard).
Owner
Author
Second review round (fix-commit delta, pi)The 3cc0b86 fix commit itself got a follow-up pi review:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #58. After a dev-DB wipe,
Seed__Demo=trueboots a fully populated app instead of empty screens.What
DemoDataSeeder— own startup scope, resolves theTenantContextto the seeded account, and drives the real handlers (record → submit → lots/movements, customer → order → items → FIFO confirm), so every downstream fact exists exactly as if a user clicked it in. Deterministic quantities — reproducible demos, noRandom.Seeds: two active flocks (45wk/20wk) + a depleted 2025 batch with a backdated 430-bird end-of-lay cull; a week of submitted graded entries per active flock with losses and sprinkled mortality (today = Draft for one flock, unrecorded for the other, so the dashboard shows both states and the "no entry" flag); three customers; one confirmed order + one open draft.
Safety
Seed__Demo=truein deploy/.env or user-secrets); prod can't accidentally get fake data.Tests (+1 → 124)
Derived test host (runtime-generated credentials) on a fresh catalog: 3 flocks incl. depleted with ledger-reduced count (450−430=20), stock > 0, confirmed + draft orders, 14+ entries; second startup no-op. Guard also verified live against the populated dev DB ("Demo seed skipped: flocks already exist").