diff --git a/backend/src/db.js b/backend/src/db.js index 306a4be..7f2fa21 100644 --- a/backend/src/db.js +++ b/backend/src/db.js @@ -60,6 +60,7 @@ db.exec(` folder_id INTEGER NOT NULL REFERENCES folders(id) ON DELETE CASCADE, shared_by INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, shared_with INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, UNIQUE(folder_id, shared_with) ); @@ -160,6 +161,10 @@ 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"); + 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"); if (!oiCols.includes('custom_price')) db.exec("ALTER TABLE order_items ADD COLUMN custom_price REAL");