Dateien nach "backend/src" hochladen
This commit is contained in:
@@ -177,4 +177,44 @@ if (!oiCols.includes('qty_in_arbeit')) db.exec("ALTER TABLE order_items ADD CO
|
||||
if (!oiCols.includes('qty_fertig')) db.exec("ALTER TABLE order_items ADD COLUMN qty_fertig INTEGER NOT NULL DEFAULT 0");
|
||||
// Bestehende Einträge: alle Stücke auf Warteliste setzen falls noch keine Qtys gesetzt
|
||||
db.exec("UPDATE order_items SET qty_warteliste=stueckzahl WHERE qty_warteliste=0 AND qty_in_arbeit=0 AND qty_fertig=0");
|
||||
|
||||
// ── Nachrichten-Migrationen ───────────────────────────────────────────────────
|
||||
if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='messages'").get()) {
|
||||
db.exec(`
|
||||
CREATE TABLE messages (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
sender_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
recipient_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
encrypted_content TEXT NOT NULL,
|
||||
iv TEXT NOT NULL,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_by_sender INTEGER NOT NULL DEFAULT 0,
|
||||
deleted_by_recipient INTEGER NOT NULL DEFAULT 0,
|
||||
read_by_recipient INTEGER NOT NULL DEFAULT 0
|
||||
)
|
||||
`);
|
||||
}
|
||||
if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='user_keys'").get()) {
|
||||
db.exec(`
|
||||
CREATE TABLE user_keys (
|
||||
user_id INTEGER PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
|
||||
public_key TEXT NOT NULL,
|
||||
updated_at DATETIME DEFAULT NULL
|
||||
)
|
||||
`);
|
||||
}
|
||||
if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='pushover_settings'").get()) {
|
||||
db.exec(`
|
||||
CREATE TABLE pushover_settings (
|
||||
user_id INTEGER PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
|
||||
user_key TEXT NOT NULL,
|
||||
app_token TEXT NOT NULL
|
||||
)
|
||||
`);
|
||||
}
|
||||
// Falls messages-Tabelle alt ist und read_by_recipient fehlt
|
||||
const msgCols = db.prepare("PRAGMA table_info(messages)").all().map(r => r.name);
|
||||
if (msgCols.length && !msgCols.includes('read_by_recipient'))
|
||||
db.exec("ALTER TABLE messages ADD COLUMN read_by_recipient INTEGER NOT NULL DEFAULT 0");
|
||||
|
||||
module.exports = db;
|
||||
|
||||
Reference in New Issue
Block a user