import { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * import_runs 增加 settings_json：保存 AI 预检确认后的
 * 列映射、校区归属、更新/重复/未匹配策略。
 */
export class AddImportRunSettings1784930000000 implements MigrationInterface {
  async up(queryRunner: QueryRunner): Promise<void> {
    if (!(await queryRunner.hasColumn('import_runs', 'settings_json'))) {
      await queryRunner.query(
        'ALTER TABLE import_runs ADD COLUMN settings_json text NULL',
      );
    }
  }

  async down(queryRunner: QueryRunner): Promise<void> {
    if (await queryRunner.hasColumn('import_runs', 'settings_json')) {
      await queryRunner.query('ALTER TABLE import_runs DROP COLUMN settings_json');
    }
  }
}
