mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-05 06:18:34 +00:00
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
|
|
import { Component } from 'src/entities/component.entity';
|
||
|
|
import { In, MigrationInterface, QueryRunner } from 'typeorm';
|
||
|
|
|
||
|
|
export class TextInputMaxHeight1701335703893 implements MigrationInterface {
|
||
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||
|
|
const componentTypes = ['TextInput', 'NumberInput', 'PasswordInput'];
|
||
|
|
const entityManager = queryRunner.manager;
|
||
|
|
|
||
|
|
const components = await entityManager.find(Component, {
|
||
|
|
where: { type: In(componentTypes) },
|
||
|
|
order: { createdAt: 'ASC' },
|
||
|
|
});
|
||
|
|
|
||
|
|
for (const component of components) {
|
||
|
|
// Ensure properties is always an object
|
||
|
|
const properties = component.properties || {};
|
||
|
|
// Check if properties.label is not present, then assign it as null
|
||
|
|
if (properties.label == undefined || null) {
|
||
|
|
properties.label = '';
|
||
|
|
}
|
||
|
|
|
||
|
|
// Update the component in the database with the modified properties
|
||
|
|
await entityManager.update(Component, component.id, { properties });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// implemented in this example
|
||
|
|
public async down(queryRunner: QueryRunner): Promise<void> {}
|
||
|
|
}
|