u
This commit is contained in:
30
src/providers/sqlite3/upgrade/3_to_4.js
Normal file
30
src/providers/sqlite3/upgrade/3_to_4.js
Normal 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user