import path from "node:path";
import { PrismaClient } from "../src/generated/prisma/client";
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
import "dotenv/config";

const databaseUrl =
  process.env.DATABASE_URL ?? `file:${path.resolve("prisma/dev.db")}`;

const prisma = new PrismaClient({
  adapter: new PrismaBetterSqlite3({ url: databaseUrl }),
});

async function main() {
  const { count } = await prisma.reading.deleteMany();
  console.log(`✓ ${count} relevé${count > 1 ? "s" : ""} supprimé${count > 1 ? "s" : ""}.`);
}

main().finally(() => prisma.$disconnect());
