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

This commit is contained in:
Weiko
2025-07-10 11:15:31 +02:00
committed by GitHub
parent 50e402af07
commit 4467de1b5c
6 changed files with 39 additions and 44 deletions

View File

@ -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'; import { WorkflowRunStatus } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';
@Command({ @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', description: 'Add enqueued status to workflow run',
}) })
export class AddEnqueuedStatusToWorkflowRunCommand extends ActiveOrSuspendedWorkspacesMigrationCommandRunner { export class AddEnqueuedStatusToWorkflowRunCommand extends ActiveOrSuspendedWorkspacesMigrationCommandRunner {
@ -65,6 +65,8 @@ export class AddEnqueuedStatusToWorkflowRunCommand extends ActiveOrSuspendedWork
this.logger.log( this.logger.log(
`Workflow run status field metadata options already contain enqueued status for workspace ${workspaceId}`, `Workflow run status field metadata options already contain enqueued status for workspace ${workspaceId}`,
); );
return;
} else if (options.dryRun) { } else if (options.dryRun) {
this.logger.log( this.logger.log(
`Would add enqueued status to workflow run status field metadata for workspace ${workspaceId}`, `Would add enqueued status to workflow run status field metadata for workspace ${workspaceId}`,

View File

@ -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'; import { WebhookWorkspaceEntity } from 'src/modules/webhook/standard-objects/webhook.workspace-entity';
@Command({ @Command({
name: 'upgrade:1-3:migrate-api-keys-webhooks-to-core', name: 'upgrade:1-1:migrate-api-keys-webhooks-to-core',
description: description:
'Migrate API keys and webhooks from workspace schemas to core schema', 'Migrate API keys and webhooks from workspace schemas to core schema',
}) })

View File

@ -1,12 +1,19 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm'; 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 { 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 { 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 { 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 { AppToken } from 'src/engine/core-modules/app-token/app-token.entity';
import { UserWorkspace } from 'src/engine/core-modules/user-workspace/user-workspace.entity'; import { UserWorkspace } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
import { User } from 'src/engine/core-modules/user/user.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 { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.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'; 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 { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
import { WorkspaceHealthModule } from 'src/engine/workspace-manager/workspace-health/workspace-health.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 { 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({ @Module({
imports: [ imports: [
@ -26,6 +32,8 @@ import { MigrateWorkflowRunStatesCommand } from 'src/database/commands/upgrade-v
UserWorkspace, UserWorkspace,
FieldMetadataEntity, FieldMetadataEntity,
ObjectMetadataEntity, ObjectMetadataEntity,
ApiKey,
Webhook,
], ],
'core', 'core',
), ),
@ -34,16 +42,22 @@ import { MigrateWorkflowRunStatesCommand } from 'src/database/commands/upgrade-v
WorkspaceMetadataVersionModule, WorkspaceMetadataVersionModule,
WorkspaceHealthModule, WorkspaceHealthModule,
TypeORMModule, TypeORMModule,
ApiKeyModule,
WebhookModule,
], ],
providers: [ providers: [
FixUpdateStandardFieldsIsLabelSyncedWithName, FixUpdateStandardFieldsIsLabelSyncedWithName,
FixSchemaArrayTypeCommand, FixSchemaArrayTypeCommand,
MigrateWorkflowRunStatesCommand, MigrateWorkflowRunStatesCommand,
MigrateApiKeysWebhooksToCoreCommand,
AddEnqueuedStatusToWorkflowRunCommand,
], ],
exports: [ exports: [
FixUpdateStandardFieldsIsLabelSyncedWithName, FixUpdateStandardFieldsIsLabelSyncedWithName,
FixSchemaArrayTypeCommand, FixSchemaArrayTypeCommand,
MigrateWorkflowRunStatesCommand, MigrateWorkflowRunStatesCommand,
MigrateApiKeysWebhooksToCoreCommand,
AddEnqueuedStatusToWorkflowRunCommand,
], ],
}) })
export class V1_1_UpgradeVersionCommandModule {} export class V1_1_UpgradeVersionCommandModule {}

View File

@ -1,17 +1,8 @@
import { Module } from '@nestjs/common'; 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({ @Module({
imports: [ imports: [],
TypeOrmModule.forFeature([Workspace, FieldMetadataEntity], 'core'), providers: [],
WorkspaceDataSourceModule, exports: [],
],
providers: [AddEnqueuedStatusToWorkflowRunCommand],
exports: [AddEnqueuedStatusToWorkflowRunCommand],
}) })
export class V1_2_UpgradeVersionCommandModule {} export class V1_2_UpgradeVersionCommandModule {}

View File

@ -1,22 +1,8 @@
import { Module } from '@nestjs/common'; 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({ @Module({
imports: [ imports: [],
TypeOrmModule.forFeature([Workspace, ApiKey, Webhook], 'core'), providers: [],
WorkspaceDataSourceModule, exports: [],
ApiKeyModule,
WebhookModule,
],
providers: [MigrateApiKeysWebhooksToCoreCommand],
exports: [MigrateApiKeysWebhooksToCoreCommand],
}) })
export class V1_3_UpgradeVersionCommandModule {} export class V1_3_UpgradeVersionCommandModule {}

View File

@ -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 { 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 { 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 { 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 { 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 { 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-1/1-1-migrate-api-keys-webhooks-to-core.command';
import { MigrateApiKeysWebhooksToCoreCommand } from 'src/database/commands/upgrade-version-command/1-3/1-3-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 { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager'; 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 { 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 { 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); const execPromise = promisify(exec);
@ -144,13 +144,13 @@ export class UpgradeCommand extends UpgradeCommandRunner {
// 1.1 Commands // 1.1 Commands
protected readonly fixSchemaArrayTypeCommand: FixSchemaArrayTypeCommand, protected readonly fixSchemaArrayTypeCommand: FixSchemaArrayTypeCommand,
protected readonly fixUpdateStandardFieldsIsLabelSyncedWithNameCommand: FixUpdateStandardFieldsIsLabelSyncedWithName, protected readonly fixUpdateStandardFieldsIsLabelSyncedWithNameCommand: FixUpdateStandardFieldsIsLabelSyncedWithName,
protected readonly migrateApiKeysWebhooksToCoreCommand: MigrateApiKeysWebhooksToCoreCommand,
// 1.2 Commands
protected readonly migrateWorkflowRunStatesCommand: MigrateWorkflowRunStatesCommand, protected readonly migrateWorkflowRunStatesCommand: MigrateWorkflowRunStatesCommand,
protected readonly addEnqueuedStatusToWorkflowRunCommand: AddEnqueuedStatusToWorkflowRunCommand, protected readonly addEnqueuedStatusToWorkflowRunCommand: AddEnqueuedStatusToWorkflowRunCommand,
// 1.2 Commands
// 1.3 Commands // 1.3 Commands
protected readonly migrateApiKeysWebhooksToCoreCommand: MigrateApiKeysWebhooksToCoreCommand,
) { ) {
super( super(
workspaceRepository, workspaceRepository,
@ -195,17 +195,19 @@ export class UpgradeCommand extends UpgradeCommandRunner {
beforeSyncMetadata: [ beforeSyncMetadata: [
this.fixUpdateStandardFieldsIsLabelSyncedWithNameCommand, this.fixUpdateStandardFieldsIsLabelSyncedWithNameCommand,
this.fixSchemaArrayTypeCommand, this.fixSchemaArrayTypeCommand,
this.migrateApiKeysWebhooksToCoreCommand,
this.addEnqueuedStatusToWorkflowRunCommand,
], ],
afterSyncMetadata: [],
};
const commands_120: VersionCommands = {
beforeSyncMetadata: [this.addEnqueuedStatusToWorkflowRunCommand],
afterSyncMetadata: [this.migrateWorkflowRunStatesCommand], afterSyncMetadata: [this.migrateWorkflowRunStatesCommand],
}; };
const commands_120: VersionCommands = {
beforeSyncMetadata: [],
afterSyncMetadata: [],
};
const commands_130: VersionCommands = { const commands_130: VersionCommands = {
beforeSyncMetadata: [this.migrateApiKeysWebhooksToCoreCommand], beforeSyncMetadata: [],
afterSyncMetadata: [], afterSyncMetadata: [],
}; };