mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-21 13:37:28 +00:00
* feat: Folder permission system * fix(group-permissions): resolve custom group validation, folder edit check, and UI inconsistencie * edit folder container && no folder in custom resource * fix the ui for custom in empty state * fix: coercion logic for folder permissions * feat: enhance folder permissions handling in app components * feat: add folder granular permissions handling in user apps permissions * feat: implement granular folder permissions in ability guard and service * feat: improve error handling for folder permissions with specific messages * feat: enhance EnvironmentSelect component to handle disabled state and improve display logic * chore: bump ee submodules * add basic framework to support platform git * feat: Update permission prop to isEditable in BaseManageGranularAccess component * chore: bump ee server submodule * fix: refine folder visibility logic based on user permissions * feat: enhance MultiValue rendering and styling for "All environments" option * fix:Uniqueness-of-data-source * revert folder changes * fix folder imports * feat: allow app lazy loading feat: import all apps of branches * feat: implement folder ownership checks and enhance app permissions handling * fix:ui changes * feat: update WorkspaceGitSyncModal UI * feat: enhance folder permissions handling for app ownership and actions * chore: clarify folder creation and deletion permissions in workspace context * fix: pull commit button & swtich branch visibility * feat: import app from git repo * fix: freezed state * remove reference of activebranchId * fix linting * fix: update folder permission labels * fixed folder permission cases * fixed css class issue * fix: datasource UI * minor fix * feat: streamline folder permissions handling by removing redundant checks and simplifying access logic * refactor: made error message consistent * fix:ui changes and PR fetching on master * fix: datasource and snapshot creation * fix: app rendering and stub loading * fix: add missing permission message for folder deletion action * refactor: consolidate forbidden messages for folder actions and maintain consistency * fix: allow pull into current branch * fix renaming of tags and reload on branch switch * fix: allow branches import from git * fix:push or tab removed * feat: streamline permission handling and improve app visibility logic * fix: remove default access denial message in AbilityGuard * fixed all user page functionality falky case * feat: add workspace-level PR fetch endpoint (returns all repo PRs without app filtering) * fix: remove app_branch_table * Fixed profile flaky case * fixed granular access flaky case * fix: allow branch creation from tags * fix: update default branch creation logic to use provider config * fix: dso and dsv operations on codebase * fix: constants reloading and refetch org git details on data * uniquness per branch * removed comment * fix: update app version handling and add is_stub column for branch-level tracking * fix workspace branch backfilling for scoped branches * added unique constraint - migration * fix: update app version unique constraint to include branchId for branch-aware handling * fix: update subproject commit reference in server/ee * chore: revert package-lock.json * chore: revert frontend/package-lock.json to main * removed banner and changed migration * minor fix * fix: remove unused import and handle UUID parse error gracefully in AppsUtilService * fix: update app stub checks to safely access app_versions * refactor: revert folder operations * fix: removed branch id logic * fix: ds migration * fix encrypted diff logic * fix: update openCreateAppModal to handle workspace branch lock * fix: subscriber filtering, freeze priority, meta hash optimization, and co_relation_id backfill * feat: add script to generate app metadata from app.json files * fix: meta script fix: backfilling of co-realtion-ids * refactor: streamline parameter formatting in workspace git sync adapter methods * Improves data source handling for workspace git sync Fixes workspace git sync to properly recognize data sources across branches by improving correlation ID handling and branch-aware data source version creation. Uses strict equality comparison in deep equal utility to prevent type coercion issues. Excludes credential_id from data source comparison to prevent unnecessary save button states. Removes is_active filter from branch data source queries to include all versions for proper synchronization. * refactor: update branch switching logic and improve error handling for data source creation * fix: migration order * 🚀 chore: update submodules to latest main after auto-merge (#15628) Co-authored-by: gsmithun4 <3417097+gsmithun4@users.noreply.github.com> * chore: update version to 3.21.8-beta across all components * fix:import app from device * fix:ui Edit&launch,folderCopy,branching dropdown in apps and ds * fix:encrypted helper text on master * fix: import from git flow * logs cleanup * fix:migration-datasource-uniqueness * fix: app on pull * chore: update server submodule hash * fix: corelation-id generation and version naming * fix: last versions deletion error fix: no multiple version creation * fix:ui and toast * chore: update server submodule hash * feat: add branch handling for app availability and improve error handling * fix: update encrypted value handling in DynamicForm and improve workspace constant validation logic * fix: improve formatting of help text in DynamicForm and enhance error message for adding constants on master branch * fix: correct version creation and pull in default branch * chore: update server submodule hash fix: remove logs from other PR * fix:data source uniquness at workspace level * fix: update header component logic for path validation and improve version import handling * chore: update server submodule to latest commit * fixed folder modal changes * fix:failed to create a query error inside apps * feat: add branchId support for data source versioning in app import/export service * fix: push & pull of tags and versions * fix: update subproject commit reference in server/ee * fix:removed gitSync logic from module rename * fix:removed switchbranch modal & allowed renaming from masted module&workflow creation * chore: Update server submodule hash * fix: change stub button to edit * refactor/git-sync-remove-modules-workflows * fix:version name for module and workflo w * fix:templet app creation * fix: add author details for branch --------- Co-authored-by: gsmithun4 <gsmithun4@gmail.com> Co-authored-by: Pratush <pratush@Pratushs-MBP.lan> Co-authored-by: Shantanu Mane <maneshantanu.20@gmail.com> Co-authored-by: parthy007 <parthadhikari1812@gmail.com> Co-authored-by: Yukti Goyal <yuktigoyal02@gmail.com> Co-authored-by: Muhsin Shah <muhsinshah21@gmail.com> Co-authored-by: Adish M <44204658+adishM98@users.noreply.github.com> Co-authored-by: gsmithun4 <3417097+gsmithun4@users.noreply.github.com> Co-authored-by: Parth <108089718+parthy007@users.noreply.github.com>
167 lines
8 KiB
TypeScript
167 lines
8 KiB
TypeScript
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
|
|
export class SeedWorkspaceBranchData1773229179000 implements MigrationInterface {
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
// 1. Create default branch for every org that has git sync configured
|
|
// Uses the actual branch name from the provider config (HTTPS / SSH / GitLab),
|
|
// falling back to 'main' only if no provider config exists.
|
|
await queryRunner.query(`
|
|
INSERT INTO organization_git_sync_branches (organization_id, branch_name, is_default)
|
|
SELECT
|
|
ogs.organization_id,
|
|
COALESCE(
|
|
ogh.github_branch,
|
|
ogsh.git_branch,
|
|
ogl.gitlab_branch,
|
|
'main'
|
|
),
|
|
true
|
|
FROM organization_git_sync ogs
|
|
LEFT JOIN organization_git_https ogh ON ogh.config_id = ogs.id
|
|
LEFT JOIN organization_git_ssh ogsh ON ogsh.config_id = ogs.id
|
|
LEFT JOIN organization_gitlab ogl ON ogl.config_id = ogs.id
|
|
ON CONFLICT (organization_id, branch_name) DO NOTHING;
|
|
`);
|
|
|
|
// 1b. Create workspace branches for pre-existing app-scoped branches.
|
|
// Old model: branches were app_versions with version_type='branch' and name = branch name.
|
|
// New model: workspace-scoped branches in organization_git_sync_branches.
|
|
// For each distinct (org, branch_name) combination, create a workspace branch entry
|
|
// with source_branch_id pointing to the default branch.
|
|
// ON CONFLICT skips if the name matches the default branch already created above.
|
|
await queryRunner.query(`
|
|
INSERT INTO organization_git_sync_branches (organization_id, branch_name, is_default, source_branch_id)
|
|
SELECT DISTINCT
|
|
a.organization_id,
|
|
av.name,
|
|
false,
|
|
wb_default.id
|
|
FROM app_versions av
|
|
JOIN apps a ON a.id = av.app_id
|
|
JOIN organization_git_sync ogs ON ogs.organization_id = a.organization_id
|
|
JOIN organization_git_sync_branches wb_default
|
|
ON wb_default.organization_id = a.organization_id AND wb_default.is_default = true
|
|
WHERE av.version_type = 'branch'
|
|
ON CONFLICT (organization_id, branch_name) DO NOTHING;
|
|
`);
|
|
|
|
// 2. Create the isDefault DSV (branch_id = NULL) for every global DS.
|
|
// This is the license-expiry fallback — always available regardless of
|
|
// branch state. Runtime code expects isDefault DSVs to have branch_id = NULL.
|
|
await queryRunner.query(`
|
|
INSERT INTO data_source_versions (data_source_id, branch_id, name, is_default, is_active)
|
|
SELECT ds.id, NULL, ds.name, true, true
|
|
FROM data_sources ds
|
|
WHERE ds.scope = 'global'
|
|
AND ds.app_version_id IS NULL
|
|
ON CONFLICT DO NOTHING;
|
|
`);
|
|
|
|
// 2b. Create main branch DSV (branch_id = default branch UUID, is_default = false).
|
|
// This is the branch-aware DSV for the main branch, separate from the
|
|
// isDefault fallback. Both start with the same options from migration.
|
|
await queryRunner.query(`
|
|
INSERT INTO data_source_versions (data_source_id, branch_id, name, is_default, is_active)
|
|
SELECT ds.id, wb.id, ds.name, false, true
|
|
FROM data_sources ds
|
|
JOIN organization_git_sync_branches wb ON wb.organization_id = ds.organization_id AND wb.is_default = true
|
|
WHERE ds.scope = 'global'
|
|
AND ds.app_version_id IS NULL
|
|
ON CONFLICT (data_source_id, branch_id) DO NOTHING;
|
|
`);
|
|
|
|
// 2c. Create feature branch DSVs for all global DS on non-default branches.
|
|
// Each feature branch gets its own DSV copied from the isDefault DSV.
|
|
// This enables per-branch DS configuration for old app-scoped branches.
|
|
await queryRunner.query(`
|
|
INSERT INTO data_source_versions (data_source_id, branch_id, name, is_default, is_active, version_from_id)
|
|
SELECT ds.id, wb.id, ds.name, false, true, default_dsv.id
|
|
FROM data_sources ds
|
|
JOIN organization_git_sync_branches wb
|
|
ON wb.organization_id = ds.organization_id AND wb.is_default = false
|
|
JOIN data_source_versions default_dsv
|
|
ON default_dsv.data_source_id = ds.id AND default_dsv.is_default = true
|
|
WHERE ds.scope = 'global'
|
|
AND ds.app_version_id IS NULL
|
|
ON CONFLICT (data_source_id, branch_id) DO NOTHING;
|
|
`);
|
|
|
|
// 3. Copy data_source_options → data_source_version_options for the isDefault DSVs
|
|
await queryRunner.query(`
|
|
INSERT INTO data_source_version_options (data_source_version_id, environment_id, options)
|
|
SELECT dsv.id, dso.environment_id, COALESCE(dso.options, '{}'::json)::jsonb
|
|
FROM data_source_options dso
|
|
JOIN data_sources ds ON ds.id = dso.data_source_id
|
|
JOIN data_source_versions dsv ON dsv.data_source_id = ds.id AND dsv.is_default = true
|
|
WHERE ds.scope = 'global'
|
|
AND ds.app_version_id IS NULL
|
|
ON CONFLICT (data_source_version_id, environment_id) DO NOTHING;
|
|
`);
|
|
|
|
// 3b. Copy DSVO from isDefault DSVs into main branch DSVs.
|
|
// Main branch starts with the same options as the isDefault fallback.
|
|
await queryRunner.query(`
|
|
INSERT INTO data_source_version_options (data_source_version_id, environment_id, options)
|
|
SELECT main_dsv.id, default_dsvo.environment_id, default_dsvo.options
|
|
FROM data_source_versions main_dsv
|
|
JOIN organization_git_sync_branches wb
|
|
ON wb.id = main_dsv.branch_id AND wb.is_default = true
|
|
JOIN data_source_versions default_dsv
|
|
ON default_dsv.data_source_id = main_dsv.data_source_id AND default_dsv.is_default = true
|
|
JOIN data_source_version_options default_dsvo
|
|
ON default_dsvo.data_source_version_id = default_dsv.id
|
|
WHERE main_dsv.is_default = false
|
|
AND main_dsv.app_version_id IS NULL
|
|
ON CONFLICT (data_source_version_id, environment_id) DO NOTHING;
|
|
`);
|
|
|
|
// 3c. Copy DSVO from isDefault DSVs into feature branch DSVs.
|
|
// Each feature branch starts with the same DS options as the default,
|
|
// matching the pre-migration behavior where all branches shared options.
|
|
// After migration, users can independently modify DS config per branch.
|
|
await queryRunner.query(`
|
|
INSERT INTO data_source_version_options (data_source_version_id, environment_id, options)
|
|
SELECT branch_dsv.id, default_dsvo.environment_id, default_dsvo.options
|
|
FROM data_source_versions branch_dsv
|
|
JOIN organization_git_sync_branches wb
|
|
ON wb.id = branch_dsv.branch_id AND wb.is_default = false
|
|
JOIN data_source_versions default_dsv
|
|
ON default_dsv.data_source_id = branch_dsv.data_source_id AND default_dsv.is_default = true
|
|
JOIN data_source_version_options default_dsvo
|
|
ON default_dsvo.data_source_version_id = default_dsv.id
|
|
WHERE branch_dsv.is_default = false
|
|
AND branch_dsv.app_version_id IS NULL
|
|
ON CONFLICT (data_source_version_id, environment_id) DO NOTHING;
|
|
`);
|
|
|
|
// 4a. Backfill branch_id on branch-type app_versions by matching name → workspace branch.
|
|
// This preserves branch identity: feature-auth → feature-auth workspace branch.
|
|
await queryRunner.query(`
|
|
UPDATE app_versions av
|
|
SET branch_id = wb.id
|
|
FROM apps a, organization_git_sync_branches wb
|
|
WHERE av.app_id = a.id
|
|
AND wb.organization_id = a.organization_id
|
|
AND wb.branch_name = av.name
|
|
AND av.version_type = 'branch'
|
|
AND av.branch_id IS NULL;
|
|
`);
|
|
|
|
// 4b. Assign remaining app_versions (version-type, or any unmatched) to the default branch.
|
|
await queryRunner.query(`
|
|
UPDATE app_versions av
|
|
SET branch_id = wb.id
|
|
FROM apps a
|
|
JOIN organization_git_sync_branches wb
|
|
ON wb.organization_id = a.organization_id AND wb.is_default = true
|
|
WHERE av.app_id = a.id
|
|
AND av.branch_id IS NULL;
|
|
`);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`DELETE FROM data_source_version_options`);
|
|
await queryRunner.query(`DELETE FROM data_source_versions`);
|
|
await queryRunner.query(`DELETE FROM organization_git_sync_branches`);
|
|
}
|
|
}
|