Skip to content

Make the admin reset reseed what it says - #320

Open
joei4cm wants to merge 2 commits into
CopilotKit:mainfrom
joei4cm:fix/205-admin-reset-reseed
Open

joei4cm wants to merge 2 commits into
CopilotKit:mainfrom
joei4cm:fix/205-admin-reset-reseed

Conversation

@joei4cm

@joei4cm joei4cm commented Dec 2, 2026 •

Copy link
Copy Markdown

Closes #205.

POST /api/admin/reset accepted reseed: true and then declined to act on it: the seed script was a top-level async IIFE with its own PrismaClient, so the route could not import it and answered reseeded: false with a note asking for a manual npx prisma db seed.

The seed module now exports seed(prisma) and keeps only that function; the CLI bootstrap moved to seed-cli.ts (pnpm db:seed and prisma db seed point there), so importing the module never seeds anything by itself. The reset route calls seed(prisma) with the client it already holds and answers reseeded: true.

The seed runs after the reset transaction has committed. If it fails, the route logs the error and answers reseeded: false with a note, because the reset itself already happened and must not be rolled back.

One thing worth flagging: the seed writes the demo dataset, including demo team members that share the outpost-dev password, so reseed is a development affordance. Say the word if you would rather it refuse outside development.

Tests:

  • vitest run src/__tests__/admin-reset-api.test.ts — 4/4 passed: a requested reseed runs the seed, an absent reseed does not, and a failed seed is reported without discarding the reset
  • vitest run in apps/web — 1216 passed, 26 skipped
  • Against a real Postgres: tsx db/src/seed-cli.ts seeds the demo dataset, and seed(prisma) with a caller-supplied client creates the same rows after a truncate
  • apps/web typecheck, next lint on the changed files, packages/outpost db typecheck and lint, Prettier, git diff --check passed
  • The copilotkit-internal:cr-loop review was not available in this environment, so the diff was reviewed by hand; the Prettier-only changes are their own commit

🤖 Generated with Claude Code

joei4cm and others added 2 commits December 3, 2026 01:42
`POST /api/admin/reset` accepted a `reseed` flag and always declined to act
on it, because the seed script ran its own top-level IIFE with its own
PrismaClient and could not be imported.

Export `seed(prisma)` from the seed module and move the CLI bootstrap to
`seed-cli.ts`, so importing the module no longer seeds anything by itself.
The reset route now calls `seed(prisma)` with the client it already holds and
reports `reseeded: true`. The seed runs after the reset transaction has
committed: a failure there is reported and the reset stands.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The seed script was not Prettier-formatted before this branch, and the CI
format check runs on every file a PR touches, so it would fail here.
Formatting only; no behaviour change.

Co-Authored-By: Claude Code <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Factory reset accepts reseed: true but cannot re-seed

1 participant