mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-06 10:46:38 +00:00
@@ -12,6 +12,7 @@ import m4 from "./scriptsPg/1.9.0";
|
|||||||
import m5 from "./scriptsPg/1.10.0";
|
import m5 from "./scriptsPg/1.10.0";
|
||||||
import m6 from "./scriptsPg/1.10.2";
|
import m6 from "./scriptsPg/1.10.2";
|
||||||
import m7 from "./scriptsPg/1.11.0";
|
import m7 from "./scriptsPg/1.11.0";
|
||||||
|
import m8 from "./scriptsPg/1.11.1";
|
||||||
|
|
||||||
// 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
|
||||||
@@ -25,6 +26,7 @@ const migrations = [
|
|||||||
{ version: "1.10.0", run: m5 },
|
{ version: "1.10.0", run: m5 },
|
||||||
{ version: "1.10.2", run: m6 },
|
{ version: "1.10.2", run: m6 },
|
||||||
{ version: "1.11.0", run: m7 },
|
{ version: "1.11.0", run: m7 },
|
||||||
|
{ version: "1.11.1", run: m8 }
|
||||||
// Add new migrations here as they are created
|
// Add new migrations here as they are created
|
||||||
] as {
|
] as {
|
||||||
version: string;
|
version: string;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import m25 from "./scriptsSqlite/1.10.0";
|
|||||||
import m26 from "./scriptsSqlite/1.10.1";
|
import m26 from "./scriptsSqlite/1.10.1";
|
||||||
import m27 from "./scriptsSqlite/1.10.2";
|
import m27 from "./scriptsSqlite/1.10.2";
|
||||||
import m28 from "./scriptsSqlite/1.11.0";
|
import m28 from "./scriptsSqlite/1.11.0";
|
||||||
|
import m29 from "./scriptsSqlite/1.11.1";
|
||||||
|
|
||||||
// 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
|
||||||
@@ -59,6 +60,7 @@ const migrations = [
|
|||||||
{ version: "1.10.1", run: m26 },
|
{ version: "1.10.1", run: m26 },
|
||||||
{ version: "1.10.2", run: m27 },
|
{ version: "1.10.2", run: m27 },
|
||||||
{ version: "1.11.0", run: m28 },
|
{ version: "1.11.0", run: m28 },
|
||||||
|
{ version: "1.11.1", run: m29 }
|
||||||
// Add new migrations here as they are created
|
// Add new migrations here as they are created
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ export default async function migration() {
|
|||||||
console.log(`Running setup script ${version}...`);
|
console.log(`Running setup script ${version}...`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
await db.execute(sql`BEGIN`);
|
||||||
|
|
||||||
// Get the first exit node with type 'gerbil'
|
// Get the first exit node with type 'gerbil'
|
||||||
const exitNodesQuery = await db.execute(
|
const exitNodesQuery = await db.execute(
|
||||||
sql`SELECT "exitNodeId" FROM "exitNodes" WHERE "type" = 'gerbil' LIMIT 1`
|
sql`SELECT "exitNodeId" FROM "exitNodes" WHERE "type" = 'gerbil' LIMIT 1`
|
||||||
@@ -32,6 +34,8 @@ export default async function migration() {
|
|||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await db.execute(sql`UPDATE "exitNodes" SET "online" = true`); // Mark exit nodes as online
|
||||||
|
|
||||||
await db.execute(sql`COMMIT`);
|
await db.execute(sql`COMMIT`);
|
||||||
console.log(`Updated sites with exit node`);
|
console.log(`Updated sites with exit node`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -11,15 +11,20 @@ export default async function migration() {
|
|||||||
const db = new Database(location);
|
const db = new Database(location);
|
||||||
|
|
||||||
db.transaction(() => {
|
db.transaction(() => {
|
||||||
const exitNodes = db.prepare(`SELECT * FROM exitNodes WHERE type = 'gerbil' LIMIT 1`).all() as {
|
const exitNodes = db
|
||||||
|
.prepare(`SELECT * FROM exitNodes WHERE type = 'gerbil' LIMIT 1`)
|
||||||
|
.all() as {
|
||||||
exitNodeId: number;
|
exitNodeId: number;
|
||||||
name: string;
|
name: string;
|
||||||
}[];
|
}[];
|
||||||
|
|
||||||
const exitNodeId = exitNodes.length > 0 ? exitNodes[0].exitNodeId : null;
|
const exitNodeId =
|
||||||
|
exitNodes.length > 0 ? exitNodes[0].exitNodeId : null;
|
||||||
|
|
||||||
// get all of the targets
|
// get all of the targets
|
||||||
const sites = db.prepare(`SELECT * FROM sites WHERE type = 'local'`).all() as {
|
const sites = db
|
||||||
|
.prepare(`SELECT * FROM sites WHERE type = 'local'`)
|
||||||
|
.all() as {
|
||||||
siteId: number;
|
siteId: number;
|
||||||
exitNodeId: number | null;
|
exitNodeId: number | null;
|
||||||
}[];
|
}[];
|
||||||
@@ -31,7 +36,9 @@ export default async function migration() {
|
|||||||
for (const site of sites) {
|
for (const site of sites) {
|
||||||
defineExitNodeOnSite.run(exitNodeId, site.siteId);
|
defineExitNodeOnSite.run(exitNodeId, site.siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
db.prepare(`UPDATE exitNodes SET online = 1`).run(); // mark exit nodes as online
|
||||||
})();
|
})();
|
||||||
|
|
||||||
console.log(`${version} migration complete`);
|
console.log(`${version} migration complete`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user