ToolJet/server/migrations/1718264886184-EnableAggregationInTooljetDatabase.ts

45 lines
2 KiB
TypeScript
Raw Normal View History

2025-02-25 06:52:50 +00:00
import { getEnvVars } from '../scripts/database-config-utils';
Feature: Aggregate and group by functionality in TJDB (#10170) * Added no codition section when aggregates are not available * Added feature to add aggregate condition and display it accordingly * Added feature to change the aggregateFx option * Added feature to update column option in the aggregate * Added feature to delete the aggregate * Disabling the group by according to valid condition but without tooltip * Added flow for deleting aggregate * feat: migration and configuration changes to support aggregation in tooljet database * added functionality for join table operations * Dropdown styles * Showing section for aggregate dropdown for joinTable operation * Added gap in multiple aggregate conditions * Added table_id in aggregate condition * Added custom placeholder Adjusted width of add condition of aggregate * Refactored logic for disable group_by field Added tooltip when group by is disabled * Updated aggregateFx to aggFx and groupBy to group_by * feat: group_by and aggregate option in list rows * added table name for aggregate dropdown value in joinTable operation * Get the group by options * value of aggregate column dropdown in join table operation * Added error and success message for aggregate deletion * Spacing adjustments * Clear the unwanted code * Updated the stucture of aggregate * Updated the structure of group_by * Fix: Query builder breaking due to undefined values * feat: logic used to aggregate on joins * Removing async * fix: app is crashing * feat: statement timeout at database level and user session level configuration can be done for ToolJet database * Added min and max width to dropdown in tooljetdb query manager * Added description * Adding width as 80 percentage when description is not avaialable * New Postgrest change for render related to Aggregate (#10175) * New Postgrest change for render related to Aggregate and group by functionality * correction in PGRST_DB_ENABLE_AGGREGATE value * Adding the env variable PGRST_DB_PRE_CONFIG * Adding the new postgrest related env changes to CE specific files * fix: updated env variable naming for aggregates * Showing description at the bottom for aggregate fx * Fixing typo error * Showing tick mark on selected item in dropdown when isMulti is false * Updated requested changes * Showing some description when option is not focused or selected * Updated the component name to AggregateFilter * fix: updated env variable to enable aggregation in tooljet database * refactor: new wrapper to create migration connection for tooljet database * fix: custom error message for aggregation errors has been handled for list_rows operation * fix: code review fixes * fix: aggregate function validation typo is updated * fix: empty validation for Select and Aggregate fields * postgrest changes for cypress * removed PGRST_DB_ENABLE_AGGREGATE --------- Co-authored-by: Ganesh Kumar <ganesh8056234@gmail.com> Co-authored-by: Adish M <44204658+adishM98@users.noreply.github.com> Co-authored-by: Adish M <adish.madhu@gmail.com>
2024-07-01 09:08:31 +00:00
import { createMigrationConnectionForToolJetDatabase } from 'src/helpers/tjdb.migration.helper';
import { MigrationInterface, QueryRunner } from 'typeorm';
export class EnableAggregationInTooljetDatabase1718264886184 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const envData = getEnvVars();
console.log('Entering Migration --- EnableAggregationInTooljetDatabase');
const tooljetDbUser = envData.TOOLJET_DB_USER;
const { tooljetDbConnection, tooljetDbManager } = await createMigrationConnectionForToolJetDatabase(
'tooljetDbAggregateMigration'
);
try {
await tooljetDbManager.transaction(async (transactionalEntityManager) => {
await transactionalEntityManager.queryRunner.query('CREATE SCHEMA IF NOT EXISTS postgrest');
console.log(`Migration: EnableAggregationInTooljetDatabase --- Created new schema 'postgrest'`);
await transactionalEntityManager.queryRunner.query(`GRANT USAGE ON SCHEMA postgrest to ${tooljetDbUser}`);
console.log(
`Migration: EnableAggregationInTooljetDatabase --- Granted 'postgrest' schema access to tooljet database user`
);
await transactionalEntityManager.queryRunner.query(`create or replace function postgrest.pre_config()
returns void as $$
select
set_config('pgrst.db_aggregates_enabled', 'true', false)
$$ language sql;
`);
console.log(
`Migration: EnableAggregationInTooljetDatabase ---- Successfully created pre_config function for postgrest`
);
await transactionalEntityManager.queryRunner.query("NOTIFY pgrst, 'reload schema'");
});
} catch (error) {
console.error('Error during migration: EnableAggregationInTooljetDatabase --- ', error);
throw error;
} finally {
await tooljetDbConnection.destroy();
Feature: Aggregate and group by functionality in TJDB (#10170) * Added no codition section when aggregates are not available * Added feature to add aggregate condition and display it accordingly * Added feature to change the aggregateFx option * Added feature to update column option in the aggregate * Added feature to delete the aggregate * Disabling the group by according to valid condition but without tooltip * Added flow for deleting aggregate * feat: migration and configuration changes to support aggregation in tooljet database * added functionality for join table operations * Dropdown styles * Showing section for aggregate dropdown for joinTable operation * Added gap in multiple aggregate conditions * Added table_id in aggregate condition * Added custom placeholder Adjusted width of add condition of aggregate * Refactored logic for disable group_by field Added tooltip when group by is disabled * Updated aggregateFx to aggFx and groupBy to group_by * feat: group_by and aggregate option in list rows * added table name for aggregate dropdown value in joinTable operation * Get the group by options * value of aggregate column dropdown in join table operation * Added error and success message for aggregate deletion * Spacing adjustments * Clear the unwanted code * Updated the stucture of aggregate * Updated the structure of group_by * Fix: Query builder breaking due to undefined values * feat: logic used to aggregate on joins * Removing async * fix: app is crashing * feat: statement timeout at database level and user session level configuration can be done for ToolJet database * Added min and max width to dropdown in tooljetdb query manager * Added description * Adding width as 80 percentage when description is not avaialable * New Postgrest change for render related to Aggregate (#10175) * New Postgrest change for render related to Aggregate and group by functionality * correction in PGRST_DB_ENABLE_AGGREGATE value * Adding the env variable PGRST_DB_PRE_CONFIG * Adding the new postgrest related env changes to CE specific files * fix: updated env variable naming for aggregates * Showing description at the bottom for aggregate fx * Fixing typo error * Showing tick mark on selected item in dropdown when isMulti is false * Updated requested changes * Showing some description when option is not focused or selected * Updated the component name to AggregateFilter * fix: updated env variable to enable aggregation in tooljet database * refactor: new wrapper to create migration connection for tooljet database * fix: custom error message for aggregation errors has been handled for list_rows operation * fix: code review fixes * fix: aggregate function validation typo is updated * fix: empty validation for Select and Aggregate fields * postgrest changes for cypress * removed PGRST_DB_ENABLE_AGGREGATE --------- Co-authored-by: Ganesh Kumar <ganesh8056234@gmail.com> Co-authored-by: Adish M <44204658+adishM98@users.noreply.github.com> Co-authored-by: Adish M <adish.madhu@gmail.com>
2024-07-01 09:08:31 +00:00
}
}
public async down(queryRunner: QueryRunner): Promise<void> {}
}