summary refs log tree commit diff
path: root/util/src/migrations/mariadb
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-13 20:45:51 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-13 20:45:51 +0200
commitde9a6f28e5a06e2727bfa82c38b9f88fcd7bda02 (patch)
tree33367f419e70cce1ddab1aef129644e88f2d8263 /util/src/migrations/mariadb
parentMerge pull request #839 from fosscord/dev/dms (diff)
downloadserver-de9a6f28e5a06e2727bfa82c38b9f88fcd7bda02.tar.xz
Do the funny thing (make user->invite cascade delet)
Diffstat (limited to 'util/src/migrations/mariadb')
-rw-r--r--util/src/migrations/mariadb/1660416072362-InvitersAreDeletable.ts56
1 files changed, 56 insertions, 0 deletions
diff --git a/util/src/migrations/mariadb/1660416072362-InvitersAreDeletable.ts b/util/src/migrations/mariadb/1660416072362-InvitersAreDeletable.ts
new file mode 100644
index 00000000..8374eafb
--- /dev/null
+++ b/util/src/migrations/mariadb/1660416072362-InvitersAreDeletable.ts
@@ -0,0 +1,56 @@
+import { MigrationInterface, QueryRunner } from "typeorm";
+
+export class InvitersAreDeletable1660416072362 implements MigrationInterface {
+    name = 'InvitersAreDeletable1660416072362'
+
+    public async up(queryRunner: QueryRunner): Promise<void> {
+        await queryRunner.query(`
+            ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\`
+        `);
+        await queryRunner.query(`
+            DROP INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\`
+        `);
+        await queryRunner.query(`
+            CREATE TABLE \`plugin_config\` (
+                \`key\` varchar(255) NOT NULL,
+                \`value\` text NULL,
+                PRIMARY KEY (\`key\`)
+            ) ENGINE = InnoDB
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`channels\`
+            ADD \`flags\` int NULL
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`channels\`
+            ADD \`default_thread_rate_limit_per_user\` int NULL
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`invites\`
+            ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION
+        `);
+    }
+
+    public async down(queryRunner: QueryRunner): Promise<void> {
+        await queryRunner.query(`
+            ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\`
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`channels\` DROP COLUMN \`default_thread_rate_limit_per_user\`
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`channels\` DROP COLUMN \`flags\`
+        `);
+        await queryRunner.query(`
+            DROP TABLE \`plugin_config\`
+        `);
+        await queryRunner.query(`
+            CREATE UNIQUE INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\` (\`settingsId\`)
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`invites\`
+            ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION
+        `);
+    }
+
+}