Skip to content

feat: preview-DB seeding + reset endpoint with deterministic results (bounty #10) - #27

Open
Kasuki354 wants to merge 2 commits into
quicksilverj2:mainfrom
Kasuki354:bounty-10-db-seeding
Open

feat: preview-DB seeding + reset endpoint with deterministic results (bounty #10)#27
Kasuki354 wants to merge 2 commits into
quicksilverj2:mainfrom
Kasuki354:bounty-10-db-seeding

Conversation

@Kasuki354

Copy link
Copy Markdown

Summary

Implements bounty #10: Preview-DB seeding + reset endpoint

Invariant

Two consecutive probe runs against a fresh preview give identical results.

Implementation

POST /admin/seed:

  • Wipes all existing data (votes, options, polls, clones) in a transaction
  • Creates deterministic seed: 1 clone (poll), 1 poll (Best framework?), 3 options (Fastify/Express/Hono), 3 votes
  • Idempotent: running twice produces identical state
  • Optional auth via x-admin-token header (only enforced if ADMIN_TOKEN env var is set)

POST /admin/reset:

  • Wipes all data in a transaction
  • Returns empty state

Both endpoints:

  • Use prisma. for atomicity
  • Log events (db.seeded, db.reset) for observability
  • Return clean JSON status

Tests:

  • Seed creates deterministic data (1 clone, 1 poll, 3 options, 3 votes)
  • Two consecutive seed+probe runs give identical results
  • Reset clears all data
  • Seed after reset works
  • Seed is idempotent (same state after running twice)
  • No regression: poll creation and voting still work after seeding

Resolves #10

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.

[bounty] Preview-DB seeding + reset endpoint

1 participant