Changelog: build_time fix im Eintrag gespeichert statt dynamisch
This commit is contained in:
@@ -332,10 +332,15 @@ if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='cha
|
||||
version TEXT NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
body TEXT NOT NULL DEFAULT '',
|
||||
build_time TEXT DEFAULT NULL,
|
||||
created_at DATETIME DEFAULT NULL
|
||||
)
|
||||
`);
|
||||
}
|
||||
// Migration: build_time Spalte
|
||||
const clCols = db.prepare("PRAGMA table_info(changelog)").all().map(r => r.name);
|
||||
if (clCols.length && !clCols.includes('build_time'))
|
||||
db.exec("ALTER TABLE changelog ADD COLUMN build_time TEXT DEFAULT NULL");
|
||||
|
||||
// ── Push-Zeitplaner ───────────────────────────────────────────────────────────
|
||||
if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='push_schedules'").get()) {
|
||||
|
||||
@@ -212,10 +212,10 @@ router.get('/changelog', authenticate, (req, res) => {
|
||||
});
|
||||
|
||||
router.post('/changelog', authenticate, requireAdmin, (req, res) => {
|
||||
const { version, title, body } = req.body;
|
||||
const { version, title, body, build_time } = req.body;
|
||||
if (!version?.trim() || !title?.trim()) return res.status(400).json({ error: 'Version und Titel erforderlich' });
|
||||
const r = db.prepare(`INSERT INTO changelog (version, title, body, created_at) VALUES (?,?,?,datetime('now','localtime'))`)
|
||||
.run(version.trim(), title.trim(), body?.trim() || '');
|
||||
const r = db.prepare(`INSERT INTO changelog (version, title, body, build_time, created_at) VALUES (?,?,?,?,datetime('now','localtime'))`)
|
||||
.run(version.trim(), title.trim(), body?.trim() || '', build_time || null);
|
||||
res.json(db.prepare('SELECT * FROM changelog WHERE id=?').get(r.lastInsertRowid));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user