mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 00:48:25 +00:00
Merge pull request #13331 from ToolJet/fix/platform-lts-mgs-5
Fix for migration on LTS to pre-release
This commit is contained in:
commit
2211fa391c
1 changed files with 28 additions and 1 deletions
|
|
@ -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
|
||||
`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue