🌱 Add re-runnable Northwind demo data seeding + DB reset for local dev#1570
Draft
jernejk wants to merge 5 commits into
Draft
🌱 Add re-runnable Northwind demo data seeding + DB reset for local dev#1570jernejk wants to merge 5 commits into
jernejk wants to merge 5 commits into
Conversation
Closes #540 - DemoDataSeeder: idempotent, hash-deterministic Northwind dataset — 60 fictional users, staff with skills/QR achievements, rewards, quizzes, 3 years of activity history with event clusters; re-runs top up gaps without duplicating - Claims generated chronologically; no user can end up with a negative balance (including open pending redemptions) - tools/DataSeeder console: seed / reset (drop -> migrate -> seed) with docker connection auto-discovery; rewards-dev db seed|reset wrapper - Aspire dashboard commands on rewards-sql: DB: Seed demo data / DB: Reset + reseed - --dev-email pre-creates the developer's own user so the app binds on first login Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…reset guard, safer conn-string building - New claims on a re-run now leave open pending-redemption costs covered (replayed claims keep their original bookkeeping, so runs stay deterministic) - reset refuses non-local servers unless --allow-remote - Auto-discovered conn string built via SqlConnectionStringBuilder; AppHost UserSecretsId parsed from the csproj with the known id as fallback - Dev QR achievement keyed by email; --dev-email documented as seed identity Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
Adds re-runnable demo-data seeding and DB reset for local dev — the seed/restore follow-up called out in #1562. A fresh clone with zero backups now gets a fully alive Rewards app in one command:
Figure: Sample of the pre-generated avatar style (60 in total, uploaded to the local blob emulator at seed time).
What you get
--years): scans, quiz passes, reward claims, and event clusters — an annual Northwind DevCon, monthly user groups, quarterly hack days — so Today / Week / Month / Year / All-time leaderboards all look real.--dev-email(required) pre-creates it with history and its own QR achievement, keyed on the login email so it binds the first time you sign in.How it works
DemoDataSeeder+ declarativeDemoDataSetin Application (beside the legacySampleDataSeeder, untouched). Seed-owned rows usedemo:*natural keys.+0/+0/+0/+0).tools/DataSeederconsole (minimal DI — no Hangfire/Firebase) auto-discovers the Aspire SQL/Azurite containers and the SA password from the AppHost user-secrets;rewards-dev db …wraps it.rewards-sql: DB: Seed demo data and DB: Reset + reseed (confirmation dialog; connection strings passed as env vars, never argv).resetforce-drops both DBs even while the stack runs (SINGLE_USER WITH ROLLBACK IMMEDIATE) and refuses non-local servers.demo-assetscontainer on first seed._docs/Aspire-Local-Dev.md+ themanage-databaseagent skill.Verified
First seed on an empty DB, then the same command again:
Sanity queries after seeding: 26 users active in the last 7 days, DevCon cohorts grow 8 → 19 → 33 across the 3 years, minimum balance across all users is +100 (never negative), 60/60 users + 7/7 rewards have blob image URLs.
Tests
6 unit tests over the real
ApplicationDbContext(EF InMemory): same-day idempotency, gap-fill top-up, no-negative-balance invariant, dev-user creation, flagship ranking, playable-quiz protection.Note
Found while building:
SubmitUserQuizCommandValidatorblocks a quiz for everyone once any user passes it (CompletedQuizzes.AnyAsync(c => c.QuizId == quizId && c.Passed)— no user filter). Not fixed here (out of scope); the seeder works around it. Worth its own issue.This is groundwork for multi-tenancy seeding (#1507 / #1511) — the Northwind dataset is a ready-made sample-tenant dataset.
Closes #540
Pair programming
✏️ Yes — JK pairing with Claude (Fable 5)
🤖 Generated with Claude Code