mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-21 21:47:17 +00:00
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
|
|
export class UpdateShowFlagForCurrencyInput1764930484535
|
|
implements MigrationInterface
|
|
{
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
const batchSize = 100;
|
|
let offset = 0;
|
|
let hasMoreData = true;
|
|
|
|
while (hasMoreData) {
|
|
const components = await queryRunner.query(
|
|
`SELECT id, properties
|
|
FROM components
|
|
WHERE type = 'CurrencyInput'
|
|
ORDER BY "created_at" ASC
|
|
LIMIT $1 OFFSET $2`,
|
|
[batchSize, offset]
|
|
);
|
|
|
|
if (components.length === 0) {
|
|
hasMoreData = false;
|
|
break;
|
|
}
|
|
|
|
await this.processUpdates(queryRunner, components);
|
|
offset += batchSize;
|
|
}
|
|
}
|
|
|
|
private async processUpdates(queryRunner: QueryRunner, components: any[]) {
|
|
for (const component of components) {
|
|
const properties = component.properties
|
|
? { ...component.properties }
|
|
: {};
|
|
|
|
if (properties.showFlag === undefined) {
|
|
properties.showFlag = {
|
|
value: true,
|
|
};
|
|
}
|
|
|
|
await queryRunner.query(
|
|
`UPDATE components
|
|
SET properties = $1
|
|
WHERE id = $2`,
|
|
[properties, component.id]
|
|
);
|
|
}
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {}
|
|
}
|