2025-07-27 10:21:27 -07:00
|
|
|
import { APP_PATH } from "@server/lib/consts";
|
|
|
|
import Database from "better-sqlite3";
|
|
|
|
import path from "path";
|
|
|
|
|
|
|
|
const version = "1.8.0";
|
|
|
|
|
|
|
|
export default async function migration() {
|
2025-07-28 17:32:15 -07:00
|
|
|
console.log(`Running setup script ${version}...`);
|
2025-07-27 10:21:27 -07:00
|
|
|
|
|
|
|
const location = path.join(APP_PATH, "db", "db.sqlite");
|
|
|
|
const db = new Database(location);
|
|
|
|
|
|
|
|
try {
|
|
|
|
db.transaction(() => {
|
|
|
|
db.exec(`
|
2025-07-28 17:32:15 -07:00
|
|
|
ALTER TABLE 'resources' ADD 'enableProxy' integer DEFAULT 1;
|
2025-07-28 17:18:51 -07:00
|
|
|
ALTER TABLE 'sites' ADD 'remoteSubnets' text;
|
2025-07-27 10:21:27 -07:00
|
|
|
ALTER TABLE 'user' ADD 'termsAcceptedTimestamp' text;
|
|
|
|
ALTER TABLE 'user' ADD 'termsVersion' text;
|
|
|
|
`);
|
|
|
|
})();
|
|
|
|
|
|
|
|
console.log("Migrated database schema");
|
|
|
|
} catch (e) {
|
|
|
|
console.log("Unable to migrate database schema");
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(`${version} migration complete`);
|
|
|
|
}
|