zerobyte/e2e/helpers/db.ts
Nico 60c0ce208d test(e2e): admin user registration (#338)
* test(e2e): admin user registration

* ci: e2e workflow

* feat: disable rate limiting env var

* test(e2e): fix order of execution in registration tests

* ci: run e2e tests before release
2026-01-15 16:13:39 +01:00

20 lines
757 B
TypeScript

import { createClient } from "@libsql/client";
import { drizzle } from "drizzle-orm/libsql";
import path from "node:path";
import { DATABASE_URL } from "~/server/core/constants";
import * as schema from "~/server/db/schema";
const sqlite = createClient({ url: `file:${path.join(process.cwd(), "data", DATABASE_URL)}` });
export const db = drizzle({ client: sqlite, schema: schema });
export const resetDatabase = async () => {
const cursor = await sqlite.execute("SELECT name FROM sqlite_master WHERE type='table'");
const tables = cursor.rows
.map((row) => row.name)
.filter((name) => name !== "sqlite_sequence" && name !== "__drizzle_migrations") as string[];
for (const table of tables) {
await sqlite.execute(`DELETE FROM ${table}`);
}
};