From a9457fc83b42ce1b677095fa63942ad47e535486 Mon Sep 17 00:00:00 2001 From: Dicken Date: Mon, 25 May 2026 22:46:52 +0200 Subject: [PATCH] =?UTF-8?q?backend/src/db.js=20gel=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/db.js | 71 ----------------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 backend/src/db.js diff --git a/backend/src/db.js b/backend/src/db.js deleted file mode 100644 index d117e04..0000000 --- a/backend/src/db.js +++ /dev/null @@ -1,71 +0,0 @@ -const Database = require('better-sqlite3'); -const bcrypt = require('bcryptjs'); -const path = require('path'); - -const db = new Database(process.env.DB_PATH || '/data/dickendock.db'); -db.pragma('journal_mode = WAL'); -db.pragma('foreign_keys = ON'); - -db.exec(` - CREATE TABLE IF NOT EXISTS users ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - username TEXT UNIQUE NOT NULL, - password_hash TEXT NOT NULL, - role TEXT NOT NULL DEFAULT 'user', - created_at DATETIME DEFAULT CURRENT_TIMESTAMP - ); - - -- Dashboard-Widgets - CREATE TABLE IF NOT EXISTS quick_links ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, - title TEXT NOT NULL, - url TEXT NOT NULL, - icon TEXT NOT NULL DEFAULT '🔗', - sort_order INTEGER DEFAULT 0 - ); - CREATE TABLE IF NOT EXISTS todos ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, - text TEXT NOT NULL, - done INTEGER NOT NULL DEFAULT 0, - sort_order INTEGER DEFAULT 0, - created_at DATETIME DEFAULT CURRENT_TIMESTAMP - ); - CREATE TABLE IF NOT EXISTS notes ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - user_id INTEGER NOT NULL UNIQUE REFERENCES users(id) ON DELETE CASCADE, - content TEXT NOT NULL DEFAULT '', - updated_at DATETIME DEFAULT CURRENT_TIMESTAMP - ); - - -- Tool: 3D-Kalkulator - CREATE TABLE IF NOT EXISTS calculations ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, - name TEXT NOT NULL, - gramm REAL NOT NULL, - stunden REAL NOT NULL, - farben INTEGER NOT NULL DEFAULT 1, - materialpreis_pro_gramm REAL NOT NULL DEFAULT 0.01, - stromverbrauch_kw REAL NOT NULL DEFAULT 0.15, - strompreis_pro_kwh REAL NOT NULL DEFAULT 0.38, - druckerpreis REAL NOT NULL DEFAULT 550, - gesamtdruckstunden REAL NOT NULL DEFAULT 5000, - verschleiss_pro_stunde REAL NOT NULL DEFAULT 0.06, - preis_freundschaft REAL NOT NULL, - preis_normal REAL NOT NULL, - preis_auftrag REAL NOT NULL, - created_at DATETIME DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME DEFAULT CURRENT_TIMESTAMP - ); -`); - -// Standard-Admin beim ersten Start anlegen -if (!db.prepare('SELECT id FROM users WHERE username = ?').get('admin')) { - db.prepare('INSERT INTO users (username, password_hash, role) VALUES (?, ?, ?)') - .run('admin', bcrypt.hashSync('admin123', 12), 'admin'); - console.log('✅ Admin angelegt: admin / admin123 → Bitte Passwort sofort ändern!'); -} - -module.exports = db;