ToolJet/server/data-migrations/1669919175280-removeRepetitionInDataSourceAndQuery.ts
vjaris42 bb9a211e55
[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 21:41:21 +05:30

38 lines
1.7 KiB
TypeScript

import { MigrationInterface, QueryRunner, TableForeignKey } from 'typeorm';
export class removeRepetitionInDataSourceAndQuery1669919175280 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await this.dropForeignKey('data_sources', 'app_id', queryRunner);
await this.dropForeignKey('data_queries', 'app_id', queryRunner);
await this.dropForeignKey('data_queries', 'app_version_id', queryRunner);
await queryRunner.dropColumn('data_sources', 'app_id');
await queryRunner.dropColumn('data_queries', 'app_id');
await queryRunner.dropColumn('data_queries', 'app_version_id');
await queryRunner.dropColumn('data_queries', 'kind');
await queryRunner.dropColumn('apps', 'definition');
await queryRunner.query('ALTER TABLE data_queries ALTER COLUMN data_source_id DROP NOT NULL;');
await queryRunner.query('ALTER TABLE data_sources ALTER COLUMN app_version_id DROP NOT NULL;');
//update data sources - add onDelete action to app_version_id
await this.dropForeignKey('data_sources', 'app_version_id', queryRunner);
await queryRunner.createForeignKey(
'data_sources',
new TableForeignKey({
columnNames: ['app_version_id'],
referencedColumnNames: ['id'],
referencedTableName: 'app_versions',
onDelete: 'CASCADE',
})
);
}
public async down(queryRunner: QueryRunner): Promise<void> {}
private async dropForeignKey(tableName: string, columnName: string, queryRunner) {
const table = await queryRunner.getTable(tableName);
const foreignKey = table.foreignKeys.find((fk) => fk.columnNames.indexOf(columnName) !== -1);
await queryRunner.dropForeignKey(tableName, foreignKey);
}
}