summary refs log tree commit diff
path: root/src/util/migration/mariadb
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/migration/mariadb')
-rw-r--r--src/util/migration/mariadb/1673609465036-templateDeleteCascade.ts12
-rw-r--r--src/util/migration/mariadb/1675045120206-webauthn.ts16
-rw-r--r--src/util/migration/mariadb/1696420827239-guildChannelOrdering.ts24
3 files changed, 16 insertions, 36 deletions
diff --git a/src/util/migration/mariadb/1673609465036-templateDeleteCascade.ts b/src/util/migration/mariadb/1673609465036-templateDeleteCascade.ts
index 483c5070..bfd1344b 100644
--- a/src/util/migration/mariadb/1673609465036-templateDeleteCascade.ts
+++ b/src/util/migration/mariadb/1673609465036-templateDeleteCascade.ts
@@ -22,20 +22,16 @@ export class templateDeleteCascade1673609465036 implements MigrationInterface {
 	name = "templateDeleteCascade1673609465036";
 
 	public async up(queryRunner: QueryRunner): Promise<void> {
+		await queryRunner.query(`ALTER TABLE \`templates\` DROP FOREIGN KEY \`FK_445d00eaaea0e60a017a5ed0c11\``);
 		await queryRunner.query(
-			`ALTER TABLE \`templates\` DROP FOREIGN KEY \`FK_445d00eaaea0e60a017a5ed0c11\``,
-		);
-		await queryRunner.query(
-			`ALTER TABLE \`templates\` ADD CONSTRAINT \`FK_445d00eaaea0e60a017a5ed0c11\` FOREIGN KEY (\`source_guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
+			`ALTER TABLE \`templates\` ADD CONSTRAINT \`FK_445d00eaaea0e60a017a5ed0c11\` FOREIGN KEY (\`source_guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`
 		);
 	}
 
 	public async down(queryRunner: QueryRunner): Promise<void> {
+		await queryRunner.query(`ALTER TABLE \`templates\` DROP FOREIGN KEY \`FK_445d00eaaea0e60a017a5ed0c11\``);
 		await queryRunner.query(
-			`ALTER TABLE \`templates\` DROP FOREIGN KEY \`FK_445d00eaaea0e60a017a5ed0c11\``,
-		);
-		await queryRunner.query(
-			`ALTER TABLE \`templates\` ADD CONSTRAINT \`FK_445d00eaaea0e60a017a5ed0c11\` FOREIGN KEY (\`source_guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`,
+			`ALTER TABLE \`templates\` ADD CONSTRAINT \`FK_445d00eaaea0e60a017a5ed0c11\` FOREIGN KEY (\`source_guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`
 		);
 	}
 }
diff --git a/src/util/migration/mariadb/1675045120206-webauthn.ts b/src/util/migration/mariadb/1675045120206-webauthn.ts
index d58ac88d..f20060af 100644
--- a/src/util/migration/mariadb/1675045120206-webauthn.ts
+++ b/src/util/migration/mariadb/1675045120206-webauthn.ts
@@ -23,23 +23,17 @@ export class webauthn1675045120206 implements MigrationInterface {
 
 	public async up(queryRunner: QueryRunner): Promise<void> {
 		await queryRunner.query(
-			`CREATE TABLE \`security_keys\` (\`id\` varchar(255) NOT NULL, \`user_id\` varchar(255) NULL, \`key_id\` varchar(255) NOT NULL, \`public_key\` varchar(255) NOT NULL, \`counter\` int NOT NULL, \`name\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`,
+			`CREATE TABLE \`security_keys\` (\`id\` varchar(255) NOT NULL, \`user_id\` varchar(255) NULL, \`key_id\` varchar(255) NOT NULL, \`public_key\` varchar(255) NOT NULL, \`counter\` int NOT NULL, \`name\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`
 		);
+		await queryRunner.query(`ALTER TABLE \`users\` ADD \`webauthn_enabled\` tinyint NOT NULL DEFAULT 0`);
 		await queryRunner.query(
-			`ALTER TABLE \`users\` ADD \`webauthn_enabled\` tinyint NOT NULL DEFAULT 0`,
-		);
-		await queryRunner.query(
-			`ALTER TABLE \`security_keys\` ADD CONSTRAINT \`FK_24c97d0771cafedce6d7163eaad\` FOREIGN KEY (\`user_id\`) REFERENCES \`users\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
+			`ALTER TABLE \`security_keys\` ADD CONSTRAINT \`FK_24c97d0771cafedce6d7163eaad\` FOREIGN KEY (\`user_id\`) REFERENCES \`users\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`
 		);
 	}
 
 	public async down(queryRunner: QueryRunner): Promise<void> {
-		await queryRunner.query(
-			`ALTER TABLE \`security_keys\` DROP FOREIGN KEY \`FK_24c97d0771cafedce6d7163eaad\``,
-		);
-		await queryRunner.query(
-			`ALTER TABLE \`users\` DROP COLUMN \`webauthn_enabled\``,
-		);
+		await queryRunner.query(`ALTER TABLE \`security_keys\` DROP FOREIGN KEY \`FK_24c97d0771cafedce6d7163eaad\``);
+		await queryRunner.query(`ALTER TABLE \`users\` DROP COLUMN \`webauthn_enabled\``);
 		await queryRunner.query(`DROP TABLE \`security_keys\``);
 	}
 }
diff --git a/src/util/migration/mariadb/1696420827239-guildChannelOrdering.ts b/src/util/migration/mariadb/1696420827239-guildChannelOrdering.ts
index 083f3680..960feb9b 100644
--- a/src/util/migration/mariadb/1696420827239-guildChannelOrdering.ts
+++ b/src/util/migration/mariadb/1696420827239-guildChannelOrdering.ts
@@ -4,31 +4,21 @@ export class guildChannelOrdering1696420827239 implements MigrationInterface {
 	name = "guildChannelOrdering1696420827239";
 
 	public async up(queryRunner: QueryRunner): Promise<void> {
-		const guilds = await queryRunner.query(
-			`SELECT id FROM guilds`,
-			undefined,
-			true,
-		);
+		const guilds = await queryRunner.query(`SELECT id FROM guilds`, undefined, true);
 
-		await queryRunner.query(
-			`ALTER TABLE guilds ADD channel_ordering text NOT NULL DEFAULT '[]'`,
-		);
+		await queryRunner.query(`ALTER TABLE guilds ADD channel_ordering text NOT NULL DEFAULT '[]'`);
 
 		for (const guild_id of guilds.records.map((x) => x.id)) {
 			const channels: Array<{ position: number; id: string }> = (
-				await queryRunner.query(
-					`SELECT id, position FROM channels WHERE guild_id = ?`,
-					[guild_id],
-					true,
-				)
+				await queryRunner.query(`SELECT id, position FROM channels WHERE guild_id = ?`, [guild_id], true)
 			).records;
 
 			channels.sort((a, b) => a.position - b.position);
 
-			await queryRunner.query(
-				`UPDATE guilds SET channel_ordering = ? WHERE id = ?`,
-				[JSON.stringify(channels.map((x) => x.id)), guild_id],
-			);
+			await queryRunner.query(`UPDATE guilds SET channel_ordering = ? WHERE id = ?`, [
+				JSON.stringify(channels.map((x) => x.id)),
+				guild_id,
+			]);
 		}
 
 		await queryRunner.query(`ALTER TABLE channels DROP COLUMN position`);