summary refs log tree commit diff
path: root/src/database/migration/postgres/1761209437070-application-commands-options-default.ts
blob: 7eba1ee21e9128b8590bcadf72b75cbecc8b4aac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { MigrationInterface, QueryRunner } from "typeorm";

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

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`UPDATE "application_commands" SET "options" = '[]' WHERE "options" IS NULL`);
        await queryRunner.query(`ALTER TABLE "application_commands" ALTER COLUMN "options" SET NOT NULL`);
        await queryRunner.query(`ALTER TABLE "application_commands" ALTER COLUMN "options" SET DEFAULT '[]'`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE "application_commands" ALTER COLUMN "options" DROP DEFAULT`);
        await queryRunner.query(`ALTER TABLE "application_commands" ALTER COLUMN "options" DROP NOT NULL`);
    }
}