31 lines
874 B
JavaScript
31 lines
874 B
JavaScript
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);
|
|
}
|
|
|