This commit is contained in:
seb
2026-10-31 20:28:39 +01:00
parent c7d1b1a5d2
commit f612c87b6e
25 changed files with 757 additions and 40 deletions

View File

@@ -0,0 +1,30 @@
import { INIT_AGENTPRINTER } from '../schema.js';
/**
* Schema 3 → 4 (SQLite):
* - Drops clientstate, clientmodel, clientserial from printeragent
* - Adds enabled to printeragent
* - Creates agentprinter table
* @param {{ exec: (sql: string) => void, assertVersion: (v: number) => Promise<void>, setVersion: (v: number) => Promise<void> }} ctx
*/
export default async function upgrade({ exec, assertVersion, setVersion }) {
await assertVersion(3);
try {
exec(`ALTER TABLE printeragent DROP COLUMN clientstate;`);
} catch {}
try {
exec(`ALTER TABLE printeragent DROP COLUMN clientmodel;`);
} catch {}
try {
exec(`ALTER TABLE printeragent DROP COLUMN clientserial;`);
} catch {}
try {
exec(`ALTER TABLE printeragent ADD COLUMN enabled INTEGER NOT NULL DEFAULT 1;`);
} catch {}
exec(INIT_AGENTPRINTER);
await setVersion(4);
}