summary refs log tree commit diff
path: root/src/util/migration/postgres/1764612754204-threads.ts
blob: e3690daccece8cf6cee2a6007b545301f719f7d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { MigrationInterface, QueryRunner } from "typeorm";

export class Threads1764612754204 implements MigrationInterface {
    name = "Threads1764612754204";

    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`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        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"`);
    }
}