import fs from 'node:fs'; import path from 'node:path'; import { drizzle } from "drizzle-orm/bun-sqlite"; import { Database } from 'bun:sqlite'; import { usersTable } from './schema'; // Importiere die Tabelle hier // biome-ignore lint/style/noNonNullAssertion: const dbPath = process.env.DB_FILE_NAME!; const dbDir = path.dirname(dbPath); // Erstelle das Verzeichnis, wenn es noch nicht existiert if (!fs.existsSync(dbDir)) { fs.mkdirSync(dbDir, { recursive: true }); } // Wenn die Datenbankdatei nicht existiert, dann erstelle sie if (!fs.existsSync(dbPath)) { fs.writeFileSync(dbPath, ''); // Leere Datei erstellen } // Datenbankverbindung herstellen const client = new Database(dbPath); // Stelle sicher, dass die Tabelle existiert client.run(` CREATE TABLE IF NOT EXISTS users_table ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, discord_id INTEGER NOT NULL UNIQUE, join_streak INTEGER, last_joined_at INTEGER, took_medication_today INTEGER NOT NULL DEFAULT 0 ); `); export const db = drizzle(client);