Skip to content

The open alternative to Salesforce, designed for AI.

Move apikey/webhook migration command from 1.3 to 1.1 (#13146)

Weiko4467de1b5ced
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-2/1-2-add-enqueued-status-to-workflow-run.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-1/1-1-add-enqueued-status-to-workflow-run.command.ts
similarity index 98%
rename from packages/twenty-server/src/database/commands/upgrade-version-command/1-2/1-2-add-enqueued-status-to-workflow-run.command.ts
rename to packages/twenty-server/src/database/commands/upgrade-version-command/1-1/1-1-add-enqueued-status-to-workflow-run.command.ts
index c7ff94853bc..9c9d2ec9fd1 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/1-2/1-2-add-enqueued-status-to-workflow-run.command.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-1/1-1-add-enqueued-status-to-workflow-run.command.ts
@@ -15,7 +15,7 @@ import { WORKFLOW_RUN_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/wo
import { WorkflowRunStatus } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';
@Command({
- name: 'upgrade:1-2:add-enqueued-status-to-workflow-run',
+ name: 'upgrade:1-1:add-enqueued-status-to-workflow-run',
description: 'Add enqueued status to workflow run',
})
export class AddEnqueuedStatusToWorkflowRunCommand extends ActiveOrSuspendedWorkspacesMigrationCommandRunner {
@@ -65,6 +65,8 @@ export class AddEnqueuedStatusToWorkflowRunCommand extends ActiveOrSuspendedWork
this.logger.log(
`Workflow run status field metadata options already contain enqueued status for workspace ${workspaceId}`,
);
+
+ return;
} else if (options.dryRun) {
this.logger.log(
`Would add enqueued status to workflow run status field metadata for workspace ${workspaceId}`,
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-3/1-3-migrate-api-keys-webhooks-to-core.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-1/1-1-migrate-api-keys-webhooks-to-core.command.ts
similarity index 99%
rename from packages/twenty-server/src/database/commands/upgrade-version-command/1-3/1-3-migrate-api-keys-webhooks-to-core.command.ts
rename to packages/twenty-server/src/database/commands/upgrade-version-command/1-1/1-1-migrate-api-keys-webhooks-to-core.command.ts
index 179601bb4fb..82c10166345 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/1-3/1-3-migrate-api-keys-webhooks-to-core.command.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-1/1-1-migrate-api-keys-webhooks-to-core.command.ts
@@ -17,7 +17,7 @@ import { ApiKeyWorkspaceEntity } from 'src/modules/api-key/standard-objects/api-
import { WebhookWorkspaceEntity } from 'src/modules/webhook/standard-objects/webhook.workspace-entity';
@Command({
- name: 'upgrade:1-3:migrate-api-keys-webhooks-to-core',
+ name: 'upgrade:1-1:migrate-api-keys-webhooks-to-core',
description:
'Migrate API keys and webhooks from workspace schemas to core schema',
})
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-1/1-1-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-1/1-1-upgrade-version-command.module.ts
index d7699d0fd33..8b6aa465c07 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/1-1/1-1-upgrade-version-command.module.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-1/1-1-upgrade-version-command.module.ts
@@ -1,12 +1,19 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
+import { AddEnqueuedStatusToWorkflowRunCommand } from 'src/database/commands/upgrade-version-command/1-1/1-1-add-enqueued-status-to-workflow-run.command';
import { FixSchemaArrayTypeCommand } from 'src/database/commands/upgrade-version-command/1-1/1-1-fix-schema-array-type.command';
import { FixUpdateStandardFieldsIsLabelSyncedWithName } from 'src/database/commands/upgrade-version-command/1-1/1-1-fix-update-standard-field-is-label-synced-with-name.command';
+import { MigrateApiKeysWebhooksToCoreCommand } from 'src/database/commands/upgrade-version-command/1-1/1-1-migrate-api-keys-webhooks-to-core.command';
+import { MigrateWorkflowRunStatesCommand } from 'src/database/commands/upgrade-version-command/1-1/1-1-migrate-workflow-run-state.command';
import { TypeORMModule } from 'src/database/typeorm/typeorm.module';
+import { ApiKey } from 'src/engine/core-modules/api-key/api-key.entity';
+import { ApiKeyModule } from 'src/engine/core-modules/api-key/api-key.module';
import { AppToken } from 'src/engine/core-modules/app-token/app-token.entity';
import { UserWorkspace } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
import { User } from 'src/engine/core-modules/user/user.entity';
+import { Webhook } from 'src/engine/core-modules/webhook/webhook.entity';
+import { WebhookModule } from 'src/engine/core-modules/webhook/webhook.module';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
@@ -14,7 +21,6 @@ import { WorkspaceMetadataVersionModule } from 'src/engine/metadata-modules/work
import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
import { WorkspaceHealthModule } from 'src/engine/workspace-manager/workspace-health/workspace-health.module';
import { WorkspaceMigrationRunnerModule } from 'src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.module';
-import { MigrateWorkflowRunStatesCommand } from 'src/database/commands/upgrade-version-command/1-1/1-1-migrate-workflow-run-state.command';
@Module({
imports: [
@@ -26,6 +32,8 @@ import { MigrateWorkflowRunStatesCommand } from 'src/database/commands/upgrade-v
UserWorkspace,
FieldMetadataEntity,
ObjectMetadataEntity,
+ ApiKey,
+ Webhook,
],
'core',
),
@@ -34,16 +42,22 @@ import { MigrateWorkflowRunStatesCommand } from 'src/database/commands/upgrade-v
WorkspaceMetadataVersionModule,
WorkspaceHealthModule,
TypeORMModule,
+ ApiKeyModule,
+ WebhookModule,
],
providers: [
FixUpdateStandardFieldsIsLabelSyncedWithName,
FixSchemaArrayTypeCommand,
MigrateWorkflowRunStatesCommand,
+ MigrateApiKeysWebhooksToCoreCommand,
+ AddEnqueuedStatusToWorkflowRunCommand,
],
exports: [
FixUpdateStandardFieldsIsLabelSyncedWithName,
FixSchemaArrayTypeCommand,
MigrateWorkflowRunStatesCommand,
+ MigrateApiKeysWebhooksToCoreCommand,
+ AddEnqueuedStatusToWorkflowRunCommand,
],
})
export class V1_1_UpgradeVersionCommandModule {}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-2/1-2-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-2/1-2-upgrade-version-command.module.ts
index 76f2aee633b..91febdf84de 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/1-2/1-2-upgrade-version-command.module.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-2/1-2-upgrade-version-command.module.ts
@@ -1,17 +1,8 @@
import { Module } from '@nestjs/common';
-import { TypeOrmModule } from '@nestjs/typeorm';
-
-import { AddEnqueuedStatusToWorkflowRunCommand } from 'src/database/commands/upgrade-version-command/1-2/1-2-add-enqueued-status-to-workflow-run.command';
-import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
-import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
-import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
@Module({
- imports: [
- TypeOrmModule.forFeature([Workspace, FieldMetadataEntity], 'core'),
- WorkspaceDataSourceModule,
- ],
- providers: [AddEnqueuedStatusToWorkflowRunCommand],
- exports: [AddEnqueuedStatusToWorkflowRunCommand],
+ imports: [],
+ providers: [],
+ exports: [],
})
export class V1_2_UpgradeVersionCommandModule {}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-3/1-3-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-3/1-3-upgrade-version-command.module.ts
index 11ceb3e1804..6e987aac56c 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/1-3/1-3-upgrade-version-command.module.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-3/1-3-upgrade-version-command.module.ts
@@ -1,22 +1,8 @@
import { Module } from '@nestjs/common';
-import { TypeOrmModule } from '@nestjs/typeorm';
-
-import { MigrateApiKeysWebhooksToCoreCommand } from 'src/database/commands/upgrade-version-command/1-3/1-3-migrate-api-keys-webhooks-to-core.command';
-import { ApiKey } from 'src/engine/core-modules/api-key/api-key.entity';
-import { ApiKeyModule } from 'src/engine/core-modules/api-key/api-key.module';
-import { Webhook } from 'src/engine/core-modules/webhook/webhook.entity';
-import { WebhookModule } from 'src/engine/core-modules/webhook/webhook.module';
-import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
-import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
@Module({
- imports: [
- TypeOrmModule.forFeature([Workspace, ApiKey, Webhook], 'core'),
- WorkspaceDataSourceModule,
- ApiKeyModule,
- WebhookModule,
- ],
- providers: [MigrateApiKeysWebhooksToCoreCommand],
- exports: [MigrateApiKeysWebhooksToCoreCommand],
+ imports: [],
+ providers: [],
+ exports: [],
})
export class V1_3_UpgradeVersionCommandModule {}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts
index 8f93b970fdd..bb0bfdf39c9 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts
@@ -21,16 +21,16 @@ import { FixStandardSelectFieldsPositionCommand } from 'src/database/commands/up
import { LowercaseUserAndInvitationEmailsCommand } from 'src/database/commands/upgrade-version-command/0-54/0-54-lowercase-user-and-invitation-emails.command';
import { MigrateDefaultAvatarUrlToUserWorkspaceCommand } from 'src/database/commands/upgrade-version-command/0-54/0-54-migrate-default-avatar-url-to-user-workspace.command';
import { DeduplicateIndexedFieldsCommand } from 'src/database/commands/upgrade-version-command/0-55/0-55-deduplicate-indexed-fields.command';
+import { AddEnqueuedStatusToWorkflowRunCommand } from 'src/database/commands/upgrade-version-command/1-1/1-1-add-enqueued-status-to-workflow-run.command';
import { FixSchemaArrayTypeCommand } from 'src/database/commands/upgrade-version-command/1-1/1-1-fix-schema-array-type.command';
import { FixUpdateStandardFieldsIsLabelSyncedWithName } from 'src/database/commands/upgrade-version-command/1-1/1-1-fix-update-standard-field-is-label-synced-with-name.command';
-import { AddEnqueuedStatusToWorkflowRunCommand } from 'src/database/commands/upgrade-version-command/1-2/1-2-add-enqueued-status-to-workflow-run.command';
-import { MigrateApiKeysWebhooksToCoreCommand } from 'src/database/commands/upgrade-version-command/1-3/1-3-migrate-api-keys-webhooks-to-core.command';
+import { MigrateApiKeysWebhooksToCoreCommand } from 'src/database/commands/upgrade-version-command/1-1/1-1-migrate-api-keys-webhooks-to-core.command';
+import { MigrateWorkflowRunStatesCommand } from 'src/database/commands/upgrade-version-command/1-1/1-1-migrate-workflow-run-state.command';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
import { SyncWorkspaceMetadataCommand } from 'src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command';
import { compareVersionMajorAndMinor } from 'src/utils/version/compare-version-minor-and-major';
-import { MigrateWorkflowRunStatesCommand } from 'src/database/commands/upgrade-version-command/1-1/1-1-migrate-workflow-run-state.command';
const execPromise = promisify(exec);
@@ -144,13 +144,13 @@ export class UpgradeCommand extends UpgradeCommandRunner {
// 1.1 Commands
protected readonly fixSchemaArrayTypeCommand: FixSchemaArrayTypeCommand,
protected readonly fixUpdateStandardFieldsIsLabelSyncedWithNameCommand: FixUpdateStandardFieldsIsLabelSyncedWithName,
-
- // 1.2 Commands
+ protected readonly migrateApiKeysWebhooksToCoreCommand: MigrateApiKeysWebhooksToCoreCommand,
protected readonly migrateWorkflowRunStatesCommand: MigrateWorkflowRunStatesCommand,
protected readonly addEnqueuedStatusToWorkflowRunCommand: AddEnqueuedStatusToWorkflowRunCommand,
+ // 1.2 Commands
+
// 1.3 Commands
- protected readonly migrateApiKeysWebhooksToCoreCommand: MigrateApiKeysWebhooksToCoreCommand,
) {
super(
workspaceRepository,
@@ -195,17 +195,19 @@ export class UpgradeCommand extends UpgradeCommandRunner {
beforeSyncMetadata: [
this.fixUpdateStandardFieldsIsLabelSyncedWithNameCommand,
this.fixSchemaArrayTypeCommand,
+ this.migrateApiKeysWebhooksToCoreCommand,
+ this.addEnqueuedStatusToWorkflowRunCommand,
],
- afterSyncMetadata: [],
+ afterSyncMetadata: [this.migrateWorkflowRunStatesCommand],
};
const commands_120: VersionCommands = {
- beforeSyncMetadata: [this.addEnqueuedStatusToWorkflowRunCommand],
- afterSyncMetadata: [this.migrateWorkflowRunStatesCommand],
+ beforeSyncMetadata: [],
+ afterSyncMetadata: [],
};
const commands_130: VersionCommands = {
- beforeSyncMetadata: [this.migrateApiKeysWebhooksToCoreCommand],
+ beforeSyncMetadata: [],
afterSyncMetadata: [],
};