diff --git a/src/util/entities/ApplicationCommand.ts b/src/util/entities/ApplicationCommand.ts index 8506d87b..82436f7a 100644 --- a/src/util/entities/ApplicationCommand.ts +++ b/src/util/entities/ApplicationCommand.ts @@ -53,8 +53,8 @@ export class ApplicationCommand extends BaseClass { @Column({ nullable: true, type: "simple-json" }) description_localizations?: Record; - @Column({ nullable: true, type: "simple-json" }) - options?: ApplicationCommandOption[]; + @Column({ type: "simple-json", default: [] }) + options: ApplicationCommandOption[]; @Column({ nullable: true, type: String }) default_member_permissions: string | null; diff --git a/src/util/migration/postgres/1761209437070-application-commands-options-default.ts b/src/util/migration/postgres/1761209437070-application-commands-options-default.ts new file mode 100644 index 00000000..1a1a4918 --- /dev/null +++ b/src/util/migration/postgres/1761209437070-application-commands-options-default.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class ApplicationCommandsOptionsDefault1761209437070 implements MigrationInterface { + name = "ApplicationCommandsOptionsDefault1761209437070"; + + public async up(queryRunner: QueryRunner): Promise { + 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 { + 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`); + } +}