Skip to content

feat: create deterministic fixtures for prisma seed - #142

Merged
3m1n3nc3 merged 2 commits into
learnault:mainfrom
Opulencechuks:deterministic-seed-fixtures
Aug 20, 2026
Merged

feat: create deterministic fixtures for prisma seed#142
3m1n3nc3 merged 2 commits into
learnault:mainfrom
Opulencechuks:deterministic-seed-fixtures

Conversation

@Opulencechuks

Copy link
Copy Markdown
Contributor

Closes #126

Description:
This PR introduces deterministic, idempotent fixtures for the Prisma development seed dataset. It isolates mock user and module data into dedicated fixture files, assigns stable local-only IDs, and ensures that repeated seeding operations safely update existing records rather than duplicating them.

Changes:

  • Created prisma/fixtures/users.ts containing local-only seed identities covering all expected test cases (verified learner, unverified learner, deactivated learner, admin, instructor, employer).
  • Created prisma/fixtures/modules.ts isolating module data fixtures.
  • Refactored prisma/seed.ts to rely on the new fixtures and implemented robust upsert operations for users, modules, completions, credentials, and transactions.
  • Updated prisma/SETUP.md with instructions on seeding and explicitly resetting the dataset using npm run seed:reset.

Acceptance Criteria Met:

  • Defined stable local-only IDs for learner, admin, instructor, and future employer.
  • Seed verified, unverified, and disabled accounts.
  • Seed current modules, completions, transactions, credentials.
  • Make repeated seed runs idempotent or explicitly resettable.
  • Exclude real addresses, secrets, and PII.
  • Fixture identities are documented as local-only in SETUP.md.

Verification Evidence (Two-run seed and fixture verification):

Run 1 Output:

🌱 Starting database seed...
✅ Upserted 6 users (learners, employers, admin)
✅ Upserted 8 modules across all categories
✅ Upserted 12 completions
✅ Upserted 8 credentials
✅ Upserted 15 transactions
✅ Upserted webhook endpoint
🎉 Seed completed successfully
📊 Totals => users: 6, modules: 8, completions: 12, credentials: 8, transactions: 15

Run 2 Output:

🌱 Starting database seed...
✅ Upserted 6 users (learners, employers, admin)
✅ Upserted 8 modules across all categories
✅ Upserted 12 completions
✅ Upserted 8 credentials
✅ Upserted 15 transactions
✅ Upserted webhook endpoint
🎉 Seed completed successfully
📊 Totals => users: 6, modules: 8, completions: 12, credentials: 8, transactions: 15

(Note: Totals remain exactly the same between runs, proving the idempotent nature of the seeding script.)


@3m1n3nc3
3m1n3nc3 merged commit a9f9a67 into learnault:main Aug 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Build Deterministic Development Seed Dataset

2 participants