2025-02-25 06:52:50 +00:00
|
|
|
import { Component } from '@entities/component.entity';
|
|
|
|
|
import { processDataInBatches } from '@helpers/migration.helper';
|
|
|
|
|
import { EntityManager, MigrationInterface, QueryRunner } from 'typeorm';
|
|
|
|
|
|
|
|
|
|
export class UpdateVisibilityFrIconComponent1737039401111 implements MigrationInterface {
|
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
|
|
|
const componentTypes = ['Icon'];
|
|
|
|
|
const batchSize = 100;
|
|
|
|
|
const entityManager = queryRunner.manager;
|
|
|
|
|
|
|
|
|
|
for (const componentType of componentTypes) {
|
|
|
|
|
await processDataInBatches(
|
|
|
|
|
entityManager,
|
|
|
|
|
async (entityManager: EntityManager) => {
|
|
|
|
|
return await entityManager.find(Component, {
|
|
|
|
|
where: { type: componentType },
|
|
|
|
|
order: { createdAt: 'ASC' },
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
async (entityManager: EntityManager, components: Component[]) => {
|
|
|
|
|
await this.processUpdates(entityManager, components);
|
|
|
|
|
},
|
|
|
|
|
batchSize
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async processUpdates(entityManager, components) {
|
|
|
|
|
for (const component of components) {
|
|
|
|
|
const properties = component.properties;
|
|
|
|
|
const styles = component.styles;
|
|
|
|
|
const general = component.general;
|
2025-04-04 09:58:05 +00:00
|
|
|
const generalStyles = component.generalStyles;
|
2025-02-25 06:52:50 +00:00
|
|
|
|
|
|
|
|
if (styles.visibility) {
|
|
|
|
|
properties.visibility = styles.visibility;
|
|
|
|
|
delete styles.visibility;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (general?.tooltip) {
|
|
|
|
|
properties.tooltip = general?.tooltip;
|
|
|
|
|
delete general?.tooltip;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-04 09:58:05 +00:00
|
|
|
if (generalStyles?.boxShadow) {
|
|
|
|
|
styles.boxShadow = generalStyles?.boxShadow;
|
|
|
|
|
delete generalStyles?.boxShadow;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-25 06:52:50 +00:00
|
|
|
await entityManager.update(Component, component.id, {
|
|
|
|
|
properties,
|
|
|
|
|
styles,
|
|
|
|
|
general,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-04 09:58:05 +00:00
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> { }
|
2025-02-25 06:52:50 +00:00
|
|
|
}
|