summary refs log tree commit diff
path: root/src/util/migration/mariadb
diff options
context:
space:
mode:
authorPuyodead1 <puyodead@proton.me>2024-04-15 13:09:20 -0400
committerGitHub <noreply@github.com>2024-04-15 13:09:20 -0400
commit2028b25902feaf29181fdead0fe150946a636447 (patch)
treef4014c5b2d82752e41355816374ae51f50229486 /src/util/migration/mariadb
parentAdd nix flake to repo (#1111) (diff)
parentFix message flags being null (diff)
downloadserver-2028b25902feaf29181fdead0fe150946a636447.tar.xz
Merge pull request #1116 from spacebarchat/patch/null-message-flags HEAD master
Fix message flags being null
Diffstat (limited to '')
-rw-r--r--src/util/migration/mariadb/1713116476900-messageFlagsNotNull.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util/migration/mariadb/1713116476900-messageFlagsNotNull.ts b/src/util/migration/mariadb/1713116476900-messageFlagsNotNull.ts
new file mode 100644
index 00000000..7be2ad70
--- /dev/null
+++ b/src/util/migration/mariadb/1713116476900-messageFlagsNotNull.ts
@@ -0,0 +1,25 @@
+import { MigrationInterface, QueryRunner } from "typeorm";
+
+export class MessageFlagsNotNull1713116476900 implements MigrationInterface {
+	name = "MessageFlagsNotNull1713116476900";
+
+	public async up(queryRunner: QueryRunner): Promise<void> {
+		await queryRunner.query(
+			"ALTER TABLE `messages` CHANGE flags flags_old integer;",
+		);
+		await queryRunner.query(
+			"ALTER TABLE `messages` ADD flags integer NOT NULL DEFAULT 0;",
+		);
+		await queryRunner.query(
+			"UPDATE `messages` SET flags = IFNULL(flags_old, 0);",
+		);
+		await queryRunner.query(
+			"ALTER TABLE `messages` DROP COLUMN flags_old;",
+		);
+	}
+
+	public async down(): Promise<void> {
+		// dont care
+		throw new Error("Migration down is not implemented.");
+	}
+}