summary refs log tree commit diff
path: root/util
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-10 18:56:46 +0200
committerGitHub <noreply@github.com>2021-10-10 18:56:46 +0200
commite7f80c4af4647c996420d23df0d20285f6a40ee2 (patch)
tree61a34fb4d1e9b6b592d5af3b21424b17d1d955ca /util
parentMerge branch 'remove-vanity-url' of https://github.com/thearcanebrony/fosscor... (diff)
parent:art: update migration script (diff)
downloadserver-e7f80c4af4647c996420d23df0d20285f6a40ee2.tar.xz
Merge branch 'master' into remove-vanity-url
Diffstat (limited to 'util')
-rw-r--r--util/src/migrations/migrate_db_engine.ts15
1 files changed, 10 insertions, 5 deletions
diff --git a/util/src/migrations/migrate_db_engine.ts b/util/src/migrations/migrate_db_engine.ts
index cd578fb2..886a16a0 100644
--- a/util/src/migrations/migrate_db_engine.ts
+++ b/util/src/migrations/migrate_db_engine.ts
@@ -58,10 +58,14 @@ async function main() {
 
 	const oldDB = await initDatabase();
 
+	const type = process.env.TO.includes("://") ? process.env.TO.split(":")[0]?.replace("+srv", "") : "sqlite";
+	const isSqlite = type.includes("sqlite");
+
 	// @ts-ignore
-	const newDB = await createConnection({
-		type: process.env.TO.split(":")[0]?.replace("+srv", ""),
-		url: process.env.TO,
+	const oldDB = await createConnection({
+		type,
+		url: isSqlite ? undefined : process.env.TO,
+		database: isSqlite ? process.env.TO : undefined,
 		entities,
 		name: "old",
 	});
@@ -71,7 +75,8 @@ async function main() {
 		for (const e of entities) {
 			const entity = e as EntityTarget<any>;
 			const entries = await oldDB.manager.find(entity);
-			//@ts-ignore
+
+			// @ts-ignore
 			console.log("migrating " + entries.length + " " + entity.name + " ...");
 
 			for (const entry of entries) {
@@ -115,7 +120,7 @@ async function main() {
 			}
 
 			// @ts-ignore
-			console.log("migrating " + entries.length + " " + entity.name + " ...");
+			console.log("migrated " + entries.length + " " + entity.name);
 		}
 	} catch (error) {
 		console.error((error as any).message);