fix: defualt options to []

This commit is contained in:
CyberL1 2025-10-23 10:56:17 +02:00
parent 8cc7527a12
commit a7ebc85066
2 changed files with 18 additions and 2 deletions

View File

@ -53,8 +53,8 @@ export class ApplicationCommand extends BaseClass {
@Column({ nullable: true, type: "simple-json" })
description_localizations?: Record<string, string>;
@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;

View File

@ -0,0 +1,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`);
}
}