ToolJet/server/migrations/1740401000000-AddIsDefaultToOrganizations.ts
Muhsin Shah C P 958cbd1d02
[improvement] Default workspace (#12834)
* Added set-default API

* Setting default workspace for super-admin onboarding

* Seperated the migrations

* Added nestjs init

* removed nestjs init

* Added: default workspace case to signup

* Fixed: instance signup

* Fixed: existed non-active user instance signup

* Added: SSO default workspace support

* Added: Default workspace chooser

* Moved some scss changes to ee folder

* Added: disable workspace default organization check

* updated the migration

* Fixing .env issue

* Removed the logs

* Remove personal workspace check from enable signup

* Fixing sign-in cases

* Fixing workspace invited user's instance signup cases

* Fixing sso workspace invited user's instance signup cases

* fixing the workspace signup issue

* Adding ee server and frontend file

* Adding ee server and frontend file

* Adding active check

* Added query fix for the migration

* Added migration logic fix

* Removed/Commented the ENABLE_ONBOARDING_QUESTIONS_FOR_ALL_SIGN_UPS env support from EE and CE

* Adding server and frontend files

* Added frontend file

* Bump version
2025-05-14 16:06:52 +05:30

30 lines
979 B
TypeScript

import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
export class AddIsDefaultToOrganizations1740401000000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
// Add is_default column
await queryRunner.addColumn(
'organizations',
new TableColumn({
name: 'is_default',
type: 'boolean',
default: false,
isNullable: false,
})
);
// Create a partial unique index to ensure only one default workspace
await queryRunner.query(`
CREATE UNIQUE INDEX idx_organizations_single_default
ON organizations (is_default)
WHERE is_default = true;
`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
// Drop the unique index first
await queryRunner.query(`DROP INDEX IF EXISTS idx_organizations_single_default;`);
// Then drop the column
await queryRunner.dropColumn('organizations', 'is_default');
}
}