feat: implement archiving functionality for counters and update related logic

This commit is contained in:
2026-08-25 13:25:21 +02:00
parent 6ccf897fc4
commit 3df1e8d7fa
9 changed files with 182 additions and 35 deletions
+8 -1
View File
@@ -29,7 +29,8 @@ db.exec(`
value INTEGER NOT NULL DEFAULT 0,
image_path TEXT,
group_id INTEGER REFERENCES groups(id) ON DELETE SET NULL,
order_index INTEGER NOT NULL DEFAULT 0
order_index INTEGER NOT NULL DEFAULT 0,
archived_at INTEGER
);
CREATE TABLE IF NOT EXISTS events (
@@ -42,5 +43,11 @@ db.exec(`
CREATE INDEX IF NOT EXISTS idx_events_date ON events(created_at);
`);
// Incremental migrations
const cols = (db.prepare("PRAGMA table_info(counters)").all() as { name: string }[]).map(c => c.name);
if (!cols.includes('archived_at')) {
db.exec('ALTER TABLE counters ADD COLUMN archived_at INTEGER');
}
export { UPLOADS_DIR };
export default db;