summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-14 00:32:15 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-14 00:32:15 +0200
commit8257e2631ae5c4237d08b48b365ce7f367de74c6 (patch)
treedf313ee16409d709c267c46c25f7bfb01fb67620
parent:pencil: improve logging (diff)
downloadserver-8257e2631ae5c4237d08b48b365ce7f367de74c6.tar.xz
:bug: fix migration + autojoin
Diffstat (limited to '')
-rw-r--r--api/src/util/Instance.ts2
-rw-r--r--util/src/migrations/migrate_db_engine.js7
2 files changed, 6 insertions, 3 deletions
diff --git a/api/src/util/Instance.ts b/api/src/util/Instance.ts
index a7b3205a..d1d9e1ab 100644
--- a/api/src/util/Instance.ts
+++ b/api/src/util/Instance.ts
@@ -8,7 +8,7 @@ export async function initInstance() {
 	// TODO: check if any current user is not part of autoJoinGuilds
 	const { autoJoin } = Config.get().guild;
 
-	if (autoJoin.enabled && autoJoin.guilds?.length) {
+	if (autoJoin.enabled && !autoJoin.guilds?.length) {
 		let guild = await Guild.findOne({});
 		if (!guild) guild = await Guild.createGuild({});
 
diff --git a/util/src/migrations/migrate_db_engine.js b/util/src/migrations/migrate_db_engine.js
index eab30bc4..79e9d86f 100644
--- a/util/src/migrations/migrate_db_engine.js
+++ b/util/src/migrations/migrate_db_engine.js
@@ -8,6 +8,7 @@ const {
 	Attachment,
 	Ban,
 	Channel,
+	ConfigEntity,
 	ConnectedAccount,
 	Emoji,
 	Guild,
@@ -32,6 +33,7 @@ async function main() {
 
 	// manually arrange them because of foreign keys
 	const entities = [
+		ConfigEntity,
 		User,
 		Guild,
 		Channel,
@@ -61,12 +63,13 @@ async function main() {
 	const isSqlite = type.includes("sqlite");
 
 	// @ts-ignore
-	const oldDB = await createConnection({
+	const newDB = await createConnection({
 		type,
 		url: isSqlite ? undefined : process.env.TO,
 		database: isSqlite ? process.env.TO : undefined,
 		entities,
-		name: "old",
+		name: "new",
+		synchronize: true,
 	});
 	let i = 0;