sendou.ink/app/db/reset.ts
Kalle 42b44614f2
Some checks are pending
E2E Tests / e2e (push) Waiting to run
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run
better-sqlite3 -> node:sqlite, get rid of ley (#3289)
2026-08-03 21:35:13 +03:00

21 lines
744 B
TypeScript

import { resetFactories } from "~/db/seed/core/defineFactory";
import { deleteAllRows } from "~/db/wipe";
import { markDatabaseClean } from "~/db/write-tracker";
/**
* Resets all data in the database by deleting all rows from every table,
* except for SQLite system tables and the kysely migration bookkeeping tables
* (`kysely_migration` and `kysely_migration_lock`).
*
* Tests do not call this — `app/test-setup.ts` runs it after every vitest test that
* wrote anything, and the e2e reset fixture before every test. Call it by hand only
* to wipe *within* a test.
*/
export const dbReset = async () => {
await deleteAllRows();
resetFactories();
// last, because the deletes above are themselves writes
markDatabaseClean();
};