feat: implement archiving functionality for counters and update related logic
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user