fix(imports): 导入向导 sheets_json 扩容为 MEDIUMTEXT

start_import_wizard 存整表行数据,TEXT(64KB) 在 430 行文件上触发
Data too long for column 'sheets_json',扩容至 MEDIUMTEXT(16MB) 并补迁移
(实际表名 import_runs,原迁移误写 import_run 导致空跑)
This commit is contained in:
2026-08-05 22:26:14 +08:00
parent 6249fefc64
commit 67e14e357c
2 changed files with 26 additions and 1 deletions

View File

@@ -20,7 +20,7 @@ export class ImportRun {
fileName: string;
/** Serialized sheet data — parsed rows are kept here for v1. */
@Column({ name: 'sheets_json', type: 'text' })
@Column({ name: 'sheets_json', type: 'mediumtext' })
sheetsJson: string;
/** Serialized ImportRunSettings — confirmed mapping/policies from AI preflight. */

View File

@@ -0,0 +1,25 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
/**
* 导入向导的 sheets_json 存整表行数据(最多 6 张工作表、数百行),
* TEXT64KB不够用会导致 start_import_wizard 报
* “Data too long for column 'sheets_json'”,扩容为 MEDIUMTEXT16MB
*/
export class WidenImportSheetsJson1786000000000 implements MigrationInterface {
async up(queryRunner: QueryRunner): Promise<void> {
if (!(await queryRunner.hasTable('import_runs'))) return;
const rows = await queryRunner.query(
`SELECT DATA_TYPE FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'import_runs' AND COLUMN_NAME = 'sheets_json'`,
);
const current = rows?.[0]?.DATA_TYPE as string | undefined;
if (current && current.toLowerCase() !== 'mediumtext') {
await queryRunner.query('ALTER TABLE `import_runs` MODIFY COLUMN `sheets_json` MEDIUMTEXT');
}
}
async down(queryRunner: QueryRunner): Promise<void> {
if (!(await queryRunner.hasTable('import_runs'))) return;
await queryRunner.query('ALTER TABLE `import_runs` MODIFY COLUMN `sheets_json` TEXT');
}
}