diff --git a/backend/src/db.js b/backend/src/db.js index 7f2fa21..04c7002 100644 --- a/backend/src/db.js +++ b/backend/src/db.js @@ -161,9 +161,12 @@ if (!ordCols.includes('bezahlt_am')) db.exec("ALTER TABLE orders ADD COLUMN beza const fileCols = db.prepare("PRAGMA table_info(files)").all().map(r => r.name); if (!fileCols.includes('folder_id')) db.exec("ALTER TABLE files ADD COLUMN folder_id INTEGER REFERENCES folders(id) ON DELETE SET NULL"); -// folder_shares migrations -const fsCols = db.prepare("PRAGMA table_info(folder_shares)").all().map(r => r.name); -if (!fsCols.includes('created_at')) db.exec("ALTER TABLE folder_shares ADD COLUMN created_at DATETIME DEFAULT CURRENT_TIMESTAMP"); +// folder_shares migrations (only if table exists) +const fsTableExists = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='folder_shares'").get(); +if (fsTableExists) { + const fsCols = db.prepare("PRAGMA table_info(folder_shares)").all().map(r => r.name); + if (!fsCols.includes('created_at')) db.exec("ALTER TABLE folder_shares ADD COLUMN created_at DATETIME DEFAULT CURRENT_TIMESTAMP"); +} const oiCols = db.prepare("PRAGMA table_info(order_items)").all().map(r => r.name); if (!oiCols.includes('stunden')) db.exec("ALTER TABLE order_items ADD COLUMN stunden REAL NOT NULL DEFAULT 0");