ToolJet/server/data-migrations/1758793442013-UpdateAppVersionStatusAndFields.ts
Rohan Lahori 5bec5a5b12
Feature/draft versioning support (#14284)
* added app_versions fields

* added data migration for backward compatibility

* added ce specific logic

* fixed ce migration (need to dev-test)

* moved to data migration

* migration changes

* added endpoint to create draft version

* backend changes

* added draft to app_import scenario

* added version description

* minor changes (needs improvement)

* fixed breaking dropdown in editor

* updated submodule commits

* revert package.json

* revert ui not used changes

* submodule changes

* reverting non used files

* ui changes

* ui changes

* ui changes

* ui changes

* ui changes

* copywriting changes

* ui changes

* ui changes

* edit version modal changes

* ui integration changes

* added button solid and removed unused css

* removed commented code from create version modal

* updated button size to use large

* ui changes

* draft version modal changes

* added sub-module commits to main

* draft version endpoint changes

* ui changes for draft version modal

* fix breaking ui

* ui changes for banner

* minor ui changes

* remove scss changes from themes file

* removed unused components (cleanup)

* removed unused components (pr cleanup)

* draft version changes

* create version modal changes

* canvas banner fixes

* comment creation logic

* refactor: version dropdown

* update endpoint changes

* fix: promote logic

* update submodule

* fix: released version and create version modal

* fix draft version creation

* minor ui changes

* minor backend fixes

* tooltip changes

* added all components in same folder

* added minor comments

* import fixes

* refactor files

* fix: overlay issues

* fix: on version creation

* fix ce bugs

* bug fixes

* bug fixes

* bug fixes

* bug fixes

* base merge

* feat: draft versioning support with UI enhancements and backend adjustments

- Updated AppCanvas to conditionally render AppCanvasBanner based on edit mode.
- Enhanced CreateDraftVersionModal to handle version selection and creation logic.
- Modified CreateVersionModal to streamline version creation process and handle commits.
- Improved ReleaseConfirmation to include development versions in release context.
- Refactored CreateDraftButton and VersionDropdownItem for better UI consistency and dark mode support.
- Updated VersionManagerDropdown to manage draft versions and improve version selection logic.
- Enhanced version switcher and promote/release buttons with dark mode styling.
- Adjusted server-side features and constants to support new draft versioning capabilities.
- Updated styles across components for better visual consistency and responsiveness.

* minor fixes

* rebase

* merge base

* update submodule

* Add data-cy attribute for draft version components

* Update cypress test cases for draft version feature

* Update failing test cases

* Update draft version test cases

* Skip older flow

* migration changes

* migration fixes

* Update the failed test cases

* removed multiple api calls

* fix: version set on draft creation

* fixes

* fix: version update on save version

* fixes

* name fix

* fix version lock banner styling

* bump version to 3.20.50-lts across all components

---------

Co-authored-by: Vijaykant Yadav <vjy239@gmail.com>
Co-authored-by: ajith-k-v <ajith.jaban@gmail.com>
Co-authored-by: gsmithun4 <gsmithun4@gmail.com>
2025-12-05 22:13:00 +05:30

52 lines
2.1 KiB
TypeScript

import { MigrationInterface, QueryRunner } from 'typeorm';
import { AppVersionStatus } from 'src/entities/app_version.entity';
export class UpdateAppVersionStatusAndFields1758793442013 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const allVersions = await queryRunner.query(`
SELECT id FROM app_versions
`);
const allDevelopmentVersionIds = await queryRunner.query(`
SELECT av.id
FROM app_versions av
INNER JOIN app_environments ae ON av.current_environment_id = ae.id
WHERE ae.name = 'development'
`);
const allReleasedVersionIds = await queryRunner.query(`
SELECT current_version_id FROM apps WHERE current_version_id IS NOT NULL
`);
const releasedVersionIds = new Set((allReleasedVersionIds || []).map((row) => row.current_version_id));
// Development versions that are NOT released (drafts)
const draftVersionStatusArray = (allDevelopmentVersionIds || [])
.map((row) => row.id)
.filter((id) => !releasedVersionIds.has(id));
const draftVersionIds = new Set(draftVersionStatusArray);
// All versions that are not drafts (published)
const publishedVersionStatusArray = (allVersions || [])
.map((row) => row.id)
.filter((id) => !draftVersionIds.has(id));
if (publishedVersionStatusArray.length) {
await queryRunner.query(`UPDATE app_versions SET status = $1 WHERE id = ANY($2::uuid[])`, [
AppVersionStatus.PUBLISHED,
publishedVersionStatusArray,
]);
}
if (draftVersionStatusArray.length) {
await queryRunner.query(`UPDATE app_versions SET status = $1 WHERE id = ANY($2::uuid[])`, [
AppVersionStatus.DRAFT,
draftVersionStatusArray,
]);
}
}
public async down(queryRunner: QueryRunner): Promise<void> {}
}
// For older versions: Set status based on environment
// - Non-development versions → PUBLISHED (they are already in a non-editable state)
// - Development versions → DRAFT (they are still in development and users may need to edit them)