summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-09-23 21:09:26 +0200
committerRory& <root@rory.gay>2025-09-29 18:38:06 +0200
commit17948c77d77d67b01aabbc3ca11df349f7e89319 (patch)
tree900e19d06a83e53fa157dda8cd15d7ecaade8e7a /src
parentAdd first half of cloud attachment uploads (diff)
downloadserver-ts-17948c77d77d67b01aabbc3ca11df349f7e89319.tar.xz
Fix ID references
Diffstat (limited to 'src')
-rw-r--r--src/util/entities/CloudAttachment.ts4
-rw-r--r--src/util/migration/postgres/1758654621365-CloudAttachmentsFixIdRefs.ts24
2 files changed, 26 insertions, 2 deletions
diff --git a/src/util/entities/CloudAttachment.ts b/src/util/entities/CloudAttachment.ts

index 02c52743d..887bce2c8 100644 --- a/src/util/entities/CloudAttachment.ts +++ b/src/util/entities/CloudAttachment.ts
@@ -34,7 +34,7 @@ export class CloudAttachment extends BaseClass { @RelationId((att: CloudAttachment) => att.user) userId: string; - @JoinColumn({ name: "userId" }) + @JoinColumn({ name: "user_id" }) @ManyToOne(() => User, { nullable: true, onDelete: "SET NULL" }) user?: User; @@ -42,7 +42,7 @@ export class CloudAttachment extends BaseClass { @RelationId((att: CloudAttachment) => att.channel) channelId?: string; // channel the file is uploaded to - @JoinColumn({ name: "channelId" }) + @JoinColumn({ name: "channel_id" }) @ManyToOne(() => Channel, { nullable: true, onDelete: "SET NULL" }) channel?: Channel; // channel the file is uploaded to diff --git a/src/util/migration/postgres/1758654621365-CloudAttachmentsFixIdRefs.ts b/src/util/migration/postgres/1758654621365-CloudAttachmentsFixIdRefs.ts new file mode 100644
index 000000000..b3be7ab07 --- /dev/null +++ b/src/util/migration/postgres/1758654621365-CloudAttachmentsFixIdRefs.ts
@@ -0,0 +1,24 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CloudAttachmentsFixIdRefs1758654621365 implements MigrationInterface { + name = 'CloudAttachmentsFixIdRefs1758654621365' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_cab965a18f8ca30293bff3d50a8"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_e6b32df2004e8ad0f488b4a2019"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP COLUMN "channelId"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP COLUMN "userId"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_8bf8cc8767e48cb482ff644fce6" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_998d5fe91008ba5b09e1322104c" FOREIGN KEY ("channel_id") REFERENCES "channels"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_998d5fe91008ba5b09e1322104c"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_8bf8cc8767e48cb482ff644fce6"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD "userId" character varying`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD "channelId" character varying`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_e6b32df2004e8ad0f488b4a2019" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_cab965a18f8ca30293bff3d50a8" FOREIGN KEY ("channelId") REFERENCES "channels"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); + } + +}