fix: preservar etiquetas técnicas extensas del Excel
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class PhaseF221LongReferenceLabels1789754350000 implements MigrationInterface {
|
||||
name = 'PhaseF221LongReferenceLabels1789754350000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
// La matriz APLICACION APP contiene denominaciones técnicas descriptivas que
|
||||
// legítimamente superan el límite histórico de 160 caracteres. No se recorta
|
||||
// información de la fuente: ampliamos sólo columnas descriptivas.
|
||||
await queryRunner.query(`ALTER TABLE asset_types ALTER COLUMN name TYPE varchar(500)`);
|
||||
await queryRunner.query(`ALTER TABLE asset_attribute_definitions ALTER COLUMN name TYPE varchar(500)`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
const rows = (await queryRunner.query(`
|
||||
SELECT
|
||||
coalesce(max(length(name)),0)::integer AS max_type_name,
|
||||
(SELECT coalesce(max(length(name)),0)::integer FROM asset_attribute_definitions) AS max_attribute_name
|
||||
FROM asset_types
|
||||
`)) as Array<{ max_type_name: number; max_attribute_name: number }>;
|
||||
|
||||
if ((rows[0]?.max_type_name ?? 0) > 160 || (rows[0]?.max_attribute_name ?? 0) > 160) {
|
||||
throw new Error('F2.2.1 no puede reducir etiquetas a 160 caracteres sin pérdida de información');
|
||||
}
|
||||
await queryRunner.query(`ALTER TABLE asset_types ALTER COLUMN name TYPE varchar(160)`);
|
||||
await queryRunner.query(`ALTER TABLE asset_attribute_definitions ALTER COLUMN name TYPE varchar(160)`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user