Merge pull request #13331 from ToolJet/fix/platform-lts-mgs-5

Fix for migration on LTS to pre-release
This commit is contained in:
Midhun G S 2025-07-11 10:54:45 +05:30 committed by GitHub
commit 2211fa391c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,18 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
export class UpdateGlobalDataSources1742905945987 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const constraintExists = await queryRunner.query(`
SELECT 1
FROM information_schema.table_constraints
WHERE constraint_name = 'chk_global_data_source_app_version_id'
AND table_name = 'data_sources'
`);
if (constraintExists && constraintExists.length > 0) {
console.log('Constraint chk_global_data_source_app_version_id already exists. Skipping migration.');
return;
}
// Step 1: Set app_version_id to NULL for existing global data sources
await queryRunner.query(`
UPDATE data_sources
@ -17,5 +29,20 @@ export class UpdateGlobalDataSources1742905945987 implements MigrationInterface
`);
}
public async down(queryRunner: QueryRunner): Promise<void> {}
public async down(queryRunner: QueryRunner): Promise<void> {
// Drop the constraint if it exists
const constraintExists = await queryRunner.query(`
SELECT 1
FROM information_schema.table_constraints
WHERE constraint_name = 'chk_global_data_source_app_version_id'
AND table_name = 'data_sources'
`);
if (constraintExists && constraintExists.length > 0) {
await queryRunner.query(`
ALTER TABLE data_sources
DROP CONSTRAINT chk_global_data_source_app_version_id
`);
}
}
}