summary refs log tree commit diff
path: root/src/database/migration/postgres/1769636200774-Threads.ts
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-06-11 23:18:02 +0200
committerRory& <root@rory.gay>2026-06-12 17:58:18 +0200
commit83e60464ad2675f09ddee02f6b166bef22f53f33 (patch)
tree9e12033c00c8420166f52c397b461cad288277fe /src/database/migration/postgres/1769636200774-Threads.ts
parentFix recursive import in database (diff)
downloadserver-ts-83e60464ad2675f09ddee02f6b166bef22f53f33.tar.xz
Move migrations to database
Diffstat (limited to 'src/database/migration/postgres/1769636200774-Threads.ts')
-rw-r--r--src/database/migration/postgres/1769636200774-Threads.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/database/migration/postgres/1769636200774-Threads.ts b/src/database/migration/postgres/1769636200774-Threads.ts
new file mode 100644

index 00000000..1a8f8fdd --- /dev/null +++ b/src/database/migration/postgres/1769636200774-Threads.ts
@@ -0,0 +1,25 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class Threads1769636200774 implements MigrationInterface { + name = "Threads1769636200774"; + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "messages" ADD "thread_id" character varying`); + await queryRunner.query(`ALTER TABLE "channels" ADD "thread_metadata" text`); + await queryRunner.query(`ALTER TABLE "channels" ADD "member_count" integer`); + await queryRunner.query(`ALTER TABLE "channels" ADD "message_count" integer`); + await queryRunner.query(`ALTER TABLE "channels" ADD "total_message_sent" integer`); + await queryRunner.query( + `ALTER TABLE "messages" ADD CONSTRAINT "FK_bb3af7f695d50083e6523290d41" FOREIGN KEY ("thread_id") REFERENCES "channels"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "messages" DROP CONSTRAINT "FK_bb3af7f695d50083e6523290d41"`); + await queryRunner.query(`ALTER TABLE "channels" DROP COLUMN "total_message_sent"`); + await queryRunner.query(`ALTER TABLE "channels" DROP COLUMN "message_count"`); + await queryRunner.query(`ALTER TABLE "channels" DROP COLUMN "member_count"`); + await queryRunner.query(`ALTER TABLE "channels" DROP COLUMN "thread_metadata"`); + await queryRunner.query(`ALTER TABLE "messages" DROP COLUMN "thread_id"`); + } +}