refactor: clear sample pages and sections to provide a clean slate for custom editing

This commit is contained in:
Daniel S
2026-08-10 00:26:02 +02:00
parent 488e024451
commit 698716c34e
4 changed files with 38 additions and 140 deletions

33
src/db/resetDb.ts Normal file
View File

@@ -0,0 +1,33 @@
import { DatabaseSync } from 'node:sqlite';
import path from 'node:path';
import fs from 'node:fs';
const DATA_DIR = process.env.DATA_DIR || path.join(process.cwd(), 'app', 'data');
const DB_PATH = path.join(DATA_DIR, 'waas.db');
export function resetDatabaseToBlankSlate(): void {
const db = new DatabaseSync(DB_PATH);
// Lösche bestehende Seiten & Sektionen
db.exec('DELETE FROM page_sections');
db.exec('DELETE FROM pages');
const now = new Date().toISOString();
// Leere Startseite anlegen (ohne vordefinierte Sektionen/Inhalte)
db.prepare('INSERT INTO pages (id, slug, title, status, homepage_id, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)').run(
'page_home',
'/',
'Startseite',
'published',
'page_home',
now,
now
);
console.log('[WaaS DB] Datenbank auf leeren Stand (Blank Slate) zurückgesetzt.');
}
if (import.meta.url === `file://${process.argv[1]}` || process.argv[1]?.endsWith('resetDb.ts')) {
resetDatabaseToBlankSlate();
}