mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-22 19:55:37 +02:00
Add migration for 1.4.0
This commit is contained in:
parent
6fc6f325a7
commit
27a0df4ed4
2 changed files with 32 additions and 2 deletions
|
@ -20,7 +20,7 @@ import m16 from "./scriptsSqlite/1.0.0";
|
||||||
import m17 from "./scriptsSqlite/1.1.0";
|
import m17 from "./scriptsSqlite/1.1.0";
|
||||||
import m18 from "./scriptsSqlite/1.2.0";
|
import m18 from "./scriptsSqlite/1.2.0";
|
||||||
import m19 from "./scriptsSqlite/1.3.0";
|
import m19 from "./scriptsSqlite/1.3.0";
|
||||||
import { setHostMeta } from "./setHostMeta";
|
import m20 from "./scriptsSqlite/1.3.0";
|
||||||
|
|
||||||
// THIS CANNOT IMPORT ANYTHING FROM THE SERVER
|
// THIS CANNOT IMPORT ANYTHING FROM THE SERVER
|
||||||
// EXCEPT FOR THE DATABASE AND THE SCHEMA
|
// EXCEPT FOR THE DATABASE AND THE SCHEMA
|
||||||
|
@ -40,7 +40,8 @@ const migrations = [
|
||||||
{ version: "1.0.0", run: m16 },
|
{ version: "1.0.0", run: m16 },
|
||||||
{ version: "1.1.0", run: m17 },
|
{ version: "1.1.0", run: m17 },
|
||||||
{ version: "1.2.0", run: m18 },
|
{ version: "1.2.0", run: m18 },
|
||||||
{ version: "1.3.0", run: m19 }
|
{ version: "1.3.0", run: m19 },
|
||||||
|
{ version: "1.4.0", run: m20 },
|
||||||
// Add new migrations here as they are created
|
// Add new migrations here as they are created
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|
29
server/setup/scriptsSqlite/1.4.0.ts
Normal file
29
server/setup/scriptsSqlite/1.4.0.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import Database from "better-sqlite3";
|
||||||
|
import path from "path";
|
||||||
|
import { encodeBase32LowerCaseNoPadding } from "@oslojs/encoding";
|
||||||
|
import { APP_PATH, configFilePath1, configFilePath2 } from "@server/lib/consts";
|
||||||
|
|
||||||
|
const version = "1.4.0";
|
||||||
|
const location = path.join(APP_PATH, "db", "db.sqlite");
|
||||||
|
|
||||||
|
export default async function migration() {
|
||||||
|
console.log(`Running setup script ${version}...`);
|
||||||
|
|
||||||
|
const db = new Database(location);
|
||||||
|
|
||||||
|
try {
|
||||||
|
db.pragma("foreign_keys = OFF");
|
||||||
|
db.transaction(() => {
|
||||||
|
db.exec(`
|
||||||
|
ALTER TABLE 'sites' ADD 'dockerSocketEnabled' integer DEFAULT true NOT NULL;
|
||||||
|
`);
|
||||||
|
})(); // <-- executes the transaction immediately
|
||||||
|
db.pragma("foreign_keys = ON");
|
||||||
|
console.log(`Migrated database schema`);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Unable to migrate database schema");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`${version} migration complete`);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue