i try to fix lmao
All checks were successful
release-tag / release-image (push) Successful in 21s

This commit is contained in:
moriese 2025-01-25 14:47:23 +01:00
parent 3b782c02fe
commit 94cc914926
2 changed files with 21 additions and 3 deletions

Binary file not shown.

View File

@ -2,17 +2,35 @@ 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: <explanation>
const dbPath = process.env.DB_FILE_NAME!;
const dbDir = path.dirname(dbPath);
// Create directory if it doesn't exist
// Erstelle das Verzeichnis, wenn es noch nicht existiert
if (!fs.existsSync(dbDir)) {
fs.mkdirSync(dbDir, { recursive: true });
}
// Ensure database file can be created
// 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);
export const db = drizzle(client);
// 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);