summary refs log tree commit diff
path: root/src/util/migrations/sqlite/1659921722863-premium_since_as_date.ts
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-08-22 22:16:11 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-08-22 22:16:11 +1000
commit8720744091e71efe0b2e5f88956e1e0a2e9ef702 (patch)
treef00521f59f3c2ece7e790f2d0b8469c051586a92 /src/util/migrations/sqlite/1659921722863-premium_since_as_date.ts
parentActually respect with_mutual_guilds (diff)
parentMerge remote-tracking branch 'Puyodead1/patch/prettier-config' into staging (diff)
downloadserver-8720744091e71efe0b2e5f88956e1e0a2e9ef702.tar.xz
Merge remote-tracking branch 'upstream/staging' into fix/sendMemberInProfile
Diffstat (limited to 'src/util/migrations/sqlite/1659921722863-premium_since_as_date.ts')
-rw-r--r--src/util/migrations/sqlite/1659921722863-premium_since_as_date.ts252
1 files changed, 252 insertions, 0 deletions
diff --git a/src/util/migrations/sqlite/1659921722863-premium_since_as_date.ts b/src/util/migrations/sqlite/1659921722863-premium_since_as_date.ts
new file mode 100644
index 00000000..788be625
--- /dev/null
+++ b/src/util/migrations/sqlite/1659921722863-premium_since_as_date.ts
@@ -0,0 +1,252 @@
+import { MigrationInterface, QueryRunner } from "typeorm";
+
+export class premiumSinceAsDate1659921722863 implements MigrationInterface {
+    name = 'premiumSinceAsDate1659921722863'
+
+    public async up(queryRunner: QueryRunner): Promise<void> {
+        await queryRunner.query(`
+            DROP INDEX "IDX_bb2bf9386ac443afbbbf9f12d3"
+        `);
+        await queryRunner.query(`
+            CREATE TABLE "temporary_members" (
+                "index" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
+                "id" varchar NOT NULL,
+                "guild_id" varchar NOT NULL,
+                "nick" varchar,
+                "joined_at" datetime NOT NULL,
+                "premium_since" bigint,
+                "deaf" boolean NOT NULL,
+                "mute" boolean NOT NULL,
+                "pending" boolean NOT NULL,
+                "settings" text NOT NULL,
+                "last_message_id" varchar,
+                "joined_by" varchar,
+                CONSTRAINT "FK_16aceddd5b89825b8ed6029ad1c" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
+                CONSTRAINT "FK_28b53062261b996d9c99fa12404" FOREIGN KEY ("id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
+            )
+        `);
+        await queryRunner.query(`
+            INSERT INTO "temporary_members"(
+                    "index",
+                    "id",
+                    "guild_id",
+                    "nick",
+                    "joined_at",
+                    "premium_since",
+                    "deaf",
+                    "mute",
+                    "pending",
+                    "settings",
+                    "last_message_id",
+                    "joined_by"
+                )
+            SELECT "index",
+                "id",
+                "guild_id",
+                "nick",
+                "joined_at",
+                "premium_since",
+                "deaf",
+                "mute",
+                "pending",
+                "settings",
+                "last_message_id",
+                "joined_by"
+            FROM "members"
+        `);
+        await queryRunner.query(`
+            DROP TABLE "members"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "temporary_members"
+                RENAME TO "members"
+        `);
+        await queryRunner.query(`
+            CREATE UNIQUE INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" ON "members" ("id", "guild_id")
+        `);
+        await queryRunner.query(`
+            DROP INDEX "IDX_bb2bf9386ac443afbbbf9f12d3"
+        `);
+        await queryRunner.query(`
+            CREATE TABLE "temporary_members" (
+                "index" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
+                "id" varchar NOT NULL,
+                "guild_id" varchar NOT NULL,
+                "nick" varchar,
+                "joined_at" datetime NOT NULL,
+                "premium_since" datetime,
+                "deaf" boolean NOT NULL,
+                "mute" boolean NOT NULL,
+                "pending" boolean NOT NULL,
+                "settings" text NOT NULL,
+                "last_message_id" varchar,
+                "joined_by" varchar,
+                CONSTRAINT "FK_16aceddd5b89825b8ed6029ad1c" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
+                CONSTRAINT "FK_28b53062261b996d9c99fa12404" FOREIGN KEY ("id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
+            )
+        `);
+        await queryRunner.query(`
+            INSERT INTO "temporary_members"(
+                    "index",
+                    "id",
+                    "guild_id",
+                    "nick",
+                    "joined_at",
+                    "premium_since",
+                    "deaf",
+                    "mute",
+                    "pending",
+                    "settings",
+                    "last_message_id",
+                    "joined_by"
+                )
+            SELECT "index",
+                "id",
+                "guild_id",
+                "nick",
+                "joined_at",
+                "premium_since",
+                "deaf",
+                "mute",
+                "pending",
+                "settings",
+                "last_message_id",
+                "joined_by"
+            FROM "members"
+        `);
+        await queryRunner.query(`
+            DROP TABLE "members"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "temporary_members"
+                RENAME TO "members"
+        `);
+        await queryRunner.query(`
+            CREATE UNIQUE INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" ON "members" ("id", "guild_id")
+        `);
+    }
+
+    public async down(queryRunner: QueryRunner): Promise<void> {
+        await queryRunner.query(`
+            DROP INDEX "IDX_bb2bf9386ac443afbbbf9f12d3"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "members"
+                RENAME TO "temporary_members"
+        `);
+        await queryRunner.query(`
+            CREATE TABLE "members" (
+                "index" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
+                "id" varchar NOT NULL,
+                "guild_id" varchar NOT NULL,
+                "nick" varchar,
+                "joined_at" datetime NOT NULL,
+                "premium_since" bigint,
+                "deaf" boolean NOT NULL,
+                "mute" boolean NOT NULL,
+                "pending" boolean NOT NULL,
+                "settings" text NOT NULL,
+                "last_message_id" varchar,
+                "joined_by" varchar,
+                CONSTRAINT "FK_16aceddd5b89825b8ed6029ad1c" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
+                CONSTRAINT "FK_28b53062261b996d9c99fa12404" FOREIGN KEY ("id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
+            )
+        `);
+        await queryRunner.query(`
+            INSERT INTO "members"(
+                    "index",
+                    "id",
+                    "guild_id",
+                    "nick",
+                    "joined_at",
+                    "premium_since",
+                    "deaf",
+                    "mute",
+                    "pending",
+                    "settings",
+                    "last_message_id",
+                    "joined_by"
+                )
+            SELECT "index",
+                "id",
+                "guild_id",
+                "nick",
+                "joined_at",
+                "premium_since",
+                "deaf",
+                "mute",
+                "pending",
+                "settings",
+                "last_message_id",
+                "joined_by"
+            FROM "temporary_members"
+        `);
+        await queryRunner.query(`
+            DROP TABLE "temporary_members"
+        `);
+        await queryRunner.query(`
+            CREATE UNIQUE INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" ON "members" ("id", "guild_id")
+        `);
+        await queryRunner.query(`
+            DROP INDEX "IDX_bb2bf9386ac443afbbbf9f12d3"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "members"
+                RENAME TO "temporary_members"
+        `);
+        await queryRunner.query(`
+            CREATE TABLE "members" (
+                "index" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
+                "id" varchar NOT NULL,
+                "guild_id" varchar NOT NULL,
+                "nick" varchar,
+                "joined_at" datetime NOT NULL,
+                "premium_since" bigint,
+                "deaf" boolean NOT NULL,
+                "mute" boolean NOT NULL,
+                "pending" boolean NOT NULL,
+                "settings" text NOT NULL,
+                "last_message_id" varchar,
+                "joined_by" varchar,
+                CONSTRAINT "FK_16aceddd5b89825b8ed6029ad1c" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
+                CONSTRAINT "FK_28b53062261b996d9c99fa12404" FOREIGN KEY ("id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
+            )
+        `);
+        await queryRunner.query(`
+            INSERT INTO "members"(
+                    "index",
+                    "id",
+                    "guild_id",
+                    "nick",
+                    "joined_at",
+                    "premium_since",
+                    "deaf",
+                    "mute",
+                    "pending",
+                    "settings",
+                    "last_message_id",
+                    "joined_by"
+                )
+            SELECT "index",
+                "id",
+                "guild_id",
+                "nick",
+                "joined_at",
+                "premium_since",
+                "deaf",
+                "mute",
+                "pending",
+                "settings",
+                "last_message_id",
+                "joined_by"
+            FROM "temporary_members"
+        `);
+        await queryRunner.query(`
+            DROP TABLE "temporary_members"
+        `);
+        await queryRunner.query(`
+            CREATE UNIQUE INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" ON "members" ("id", "guild_id")
+        `);
+    }
+
+}