ToolJet/server/data-migrations/1677822012965-AlterOrganizationIdInAppEnvironments.ts

28 lines
1 KiB
TypeScript
Raw Normal View History

2025-02-25 06:52:50 +00:00
import { AppEnvironment } from '@entities/app_environments.entity';
[Feature] :: Global datasources (#5504) * add: columns and migrations for data queries and sources * add: migrations for app environments * fix: datasources and queries api * fix: import apis * add: radixui colors * create: global datasource page * fix: version creation not including global datasources queries * fix: version deletion failure * fix: ui and other bugs * add: check for abilities on global ds * fix: bugs * fix: existing test cases * fix: migration and bugs * fix: rest api oauthorize bugs * hide: add button for local ds * fix: query bugs * fix: new organization environment creation * fix: local ds label showing for new apps * fix: on page load queries for preview app and published app * fix: import bugs from v1 * fix: merge conflicts * fix: import apis * fix: apss with mulit envs * fix: ui bugs * fix: environments not being created on db:seed * fix: ui bugs * fix: route settings for global datasources * fix: customer dashboard template * fix: local ds queries not being saved * fix: runpy issues * changes: ui * fix: migration issues * fix: ui * hide datasources when no local datasources * fix: test cases * fix: unit test cases and global queries on app import/export * cleanup * add: package-lock file * undo: migration rename * cleanup * fix: ui bugs * migration fixes * fix: dark mode issues * fix: change datasource failing on query create mode * fix: workspace selector issues * fix: clickoutside for change scope option * migration changes * fix: open api issue * reverting configs changes * [Fix] Global datasources & Environment Id issue (#5830) * fix: oauth env id issue * code changes --------- Co-authored-by: gsmithun4 <gsmithun4@gmail.com> Co-authored-by: Muhsin Shah <muhsinshah21@gmail.com>
2023-03-24 16:11:21 +00:00
import { MigrationInterface, QueryRunner, TableForeignKey } from 'typeorm';
export class AlterOrganizationIdInAppEnvironments1677822012965 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const entityManager = queryRunner.manager;
//Delete old app_environments which are not under organizations
await entityManager.delete(AppEnvironment, { organizationId: null });
//Add not null constrain to organization_id column
await queryRunner.query('alter table app_environments alter column organization_id set not null');
//Add Foreign key and delete constraints on organization_id column
await queryRunner.createForeignKey(
'app_environments',
new TableForeignKey({
columnNames: ['organization_id'],
referencedColumnNames: ['id'],
referencedTableName: 'organizations',
onDelete: 'CASCADE',
})
);
}
public async down(queryRunner: QueryRunner): Promise<void> {}
}