summary refs log tree commit diff
path: root/src/util/migration
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/migration')
-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
-rw-r--r--src/util/migration/mysql/1673609465036-templateDeleteCascade.ts12
-rw-r--r--src/util/migration/mysql/1675045120206-webauthn.ts16
-rw-r--r--src/util/migration/mysql/1696420827239-guildChannelOrdering.ts24
-rw-r--r--src/util/migration/postgres/1673609867556-templateDeleteCascade.ts12
-rw-r--r--src/util/migration/postgres/1675044825710-webauthn.ts16
-rw-r--r--src/util/migration/postgres/1696420827239-guildChannelOrdering.ts24
9 files changed, 48 insertions, 108 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`); diff --git a/src/util/migration/mysql/1673609465036-templateDeleteCascade.ts b/src/util/migration/mysql/1673609465036-templateDeleteCascade.ts
index 483c5070..bfd1344b 100644 --- a/src/util/migration/mysql/1673609465036-templateDeleteCascade.ts +++ b/src/util/migration/mysql/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/mysql/1675045120206-webauthn.ts b/src/util/migration/mysql/1675045120206-webauthn.ts
index d58ac88d..f20060af 100644 --- a/src/util/migration/mysql/1675045120206-webauthn.ts +++ b/src/util/migration/mysql/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/mysql/1696420827239-guildChannelOrdering.ts b/src/util/migration/mysql/1696420827239-guildChannelOrdering.ts
index 083f3680..960feb9b 100644 --- a/src/util/migration/mysql/1696420827239-guildChannelOrdering.ts +++ b/src/util/migration/mysql/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`); diff --git a/src/util/migration/postgres/1673609867556-templateDeleteCascade.ts b/src/util/migration/postgres/1673609867556-templateDeleteCascade.ts
index 504ed557..33c72dea 100644 --- a/src/util/migration/postgres/1673609867556-templateDeleteCascade.ts +++ b/src/util/migration/postgres/1673609867556-templateDeleteCascade.ts
@@ -22,20 +22,16 @@ export class templateDeleteCascade1673609867556 implements MigrationInterface { name = "templateDeleteCascade1673609867556"; public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "templates" DROP CONSTRAINT "FK_445d00eaaea0e60a017a5ed0c11"`); await queryRunner.query( - `ALTER TABLE "templates" DROP CONSTRAINT "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 CONSTRAINT "FK_445d00eaaea0e60a017a5ed0c11"`); await queryRunner.query( - `ALTER TABLE "templates" DROP CONSTRAINT "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/postgres/1675044825710-webauthn.ts b/src/util/migration/postgres/1675044825710-webauthn.ts
index 4b32d6c7..749ff90a 100644 --- a/src/util/migration/postgres/1675044825710-webauthn.ts +++ b/src/util/migration/postgres/1675044825710-webauthn.ts
@@ -23,23 +23,17 @@ export class webauthn1675044825710 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise<void> { await queryRunner.query( - `CREATE TABLE "security_keys" ("id" character varying NOT NULL, "user_id" character varying, "key_id" character varying NOT NULL, "public_key" character varying NOT NULL, "counter" integer NOT NULL, "name" character varying NOT NULL, CONSTRAINT "PK_6e95cdd91779e7cca06d1fff89c" PRIMARY KEY ("id"))`, + `CREATE TABLE "security_keys" ("id" character varying NOT NULL, "user_id" character varying, "key_id" character varying NOT NULL, "public_key" character varying NOT NULL, "counter" integer NOT NULL, "name" character varying NOT NULL, CONSTRAINT "PK_6e95cdd91779e7cca06d1fff89c" PRIMARY KEY ("id"))` ); + await queryRunner.query(`ALTER TABLE "users" ADD "webauthn_enabled" boolean NOT NULL DEFAULT false`); await queryRunner.query( - `ALTER TABLE "users" ADD "webauthn_enabled" boolean NOT NULL DEFAULT false`, - ); - 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 CONSTRAINT "FK_24c97d0771cafedce6d7163eaad"`, - ); - await queryRunner.query( - `ALTER TABLE "users" DROP COLUMN "webauthn_enabled"`, - ); + await queryRunner.query(`ALTER TABLE "security_keys" DROP CONSTRAINT "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/postgres/1696420827239-guildChannelOrdering.ts b/src/util/migration/postgres/1696420827239-guildChannelOrdering.ts
index 6fc80ffd..de876ff9 100644 --- a/src/util/migration/postgres/1696420827239-guildChannelOrdering.ts +++ b/src/util/migration/postgres/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 = $1`, - [guild_id], - true, - ) + await queryRunner.query(`SELECT id, position FROM channels WHERE guild_id = $1`, [guild_id], true) ).records; channels.sort((a, b) => a.position - b.position); - await queryRunner.query( - `UPDATE guilds SET channel_ordering = $1 WHERE id = $2`, - [JSON.stringify(channels.map((x) => x.id)), guild_id], - ); + await queryRunner.query(`UPDATE guilds SET channel_ordering = $1 WHERE id = $2`, [ + JSON.stringify(channels.map((x) => x.id)), + guild_id, + ]); } await queryRunner.query(`ALTER TABLE channels DROP COLUMN position`);