-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add upgrade 0.35 command module #9175
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
|
||
import { Command } from 'nest-commander'; | ||
import { Repository } from 'typeorm'; | ||
|
||
import { ActiveWorkspacesCommandRunner } from 'src/database/commands/active-workspaces.command'; | ||
import { BaseCommandOptions } from 'src/database/commands/base.command'; | ||
import { PhoneCallingCodeCreateColumnCommand } from 'src/database/commands/upgrade-version/0-35/0-35-phone-calling-code-create-column.command'; | ||
import { RecordPositionBackfillCommand } from 'src/database/commands/upgrade-version/0-35/0-35-record-position-backfill.command'; | ||
import { ViewGroupNoValueBackfillCommand } from 'src/database/commands/upgrade-version/0-35/0-35-view-group-no-value-backfill.command'; | ||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; | ||
import { SyncWorkspaceMetadataCommand } from 'src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command'; | ||
|
||
@Command({ | ||
name: 'upgrade-0.35', | ||
description: 'Upgrade to 0.35', | ||
}) | ||
export class UpgradeTo0_35Command extends ActiveWorkspacesCommandRunner { | ||
constructor( | ||
@InjectRepository(Workspace, 'core') | ||
protected readonly workspaceRepository: Repository<Workspace>, | ||
private readonly viewGroupNoValueBackfillCommand: ViewGroupNoValueBackfillCommand, | ||
private readonly syncWorkspaceMetadataCommand: SyncWorkspaceMetadataCommand, | ||
private readonly phoneCallingCodeCreateColumnCommand: PhoneCallingCodeCreateColumnCommand, | ||
private readonly recordPositionBackfillCommand: RecordPositionBackfillCommand, | ||
) { | ||
super(workspaceRepository); | ||
} | ||
|
||
async executeActiveWorkspacesCommand( | ||
passedParam: string[], | ||
options: BaseCommandOptions, | ||
workspaceIds: string[], | ||
): Promise<void> { | ||
this.logger.log( | ||
'Running command to upgrade to 0.40: must start with phone calling code otherwise SyncMetadata will fail', | ||
); | ||
|
||
await this.recordPositionBackfillCommand.executeActiveWorkspacesCommand( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: No error handling around sequential commands. If one fails, database could be left in inconsistent state. Consider wrapping in try/catch with rollback capability. |
||
passedParam, | ||
options, | ||
workspaceIds, | ||
); | ||
|
||
await this.phoneCallingCodeCreateColumnCommand.executeActiveWorkspacesCommand( | ||
passedParam, | ||
options, | ||
workspaceIds, | ||
); | ||
|
||
await this.viewGroupNoValueBackfillCommand.executeActiveWorkspacesCommand( | ||
passedParam, | ||
options, | ||
workspaceIds, | ||
); | ||
|
||
await this.syncWorkspaceMetadataCommand.executeActiveWorkspacesCommand( | ||
passedParam, | ||
{ | ||
...options, | ||
force: true, | ||
}, | ||
workspaceIds, | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
|
||
import { PhoneCallingCodeCreateColumnCommand } from 'src/database/commands/upgrade-version/0-35/0-35-phone-calling-code-create-column.command'; | ||
import { RecordPositionBackfillCommand } from 'src/database/commands/upgrade-version/0-35/0-35-record-position-backfill.command'; | ||
import { UpgradeTo0_35Command } from 'src/database/commands/upgrade-version/0-35/0-35-upgrade-version.command'; | ||
import { ViewGroupNoValueBackfillCommand } from 'src/database/commands/upgrade-version/0-35/0-35-view-group-no-value-backfill.command'; | ||
import { RecordPositionBackfillModule } from 'src/engine/api/graphql/workspace-query-runner/services/record-position-backfill-module'; | ||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; | ||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; | ||
import { FieldMetadataModule } from 'src/engine/metadata-modules/field-metadata/field-metadata.module'; | ||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity'; | ||
import { SearchModule } from 'src/engine/metadata-modules/search/search.module'; | ||
import { WorkspaceMetadataVersionModule } from 'src/engine/metadata-modules/workspace-metadata-version/workspace-metadata-version.module'; | ||
import { WorkspaceMigrationFactory } from 'src/engine/metadata-modules/workspace-migration/workspace-migration.factory'; | ||
import { WorkspaceMigrationModule } from 'src/engine/metadata-modules/workspace-migration/workspace-migration.module'; | ||
import { WorkspaceMigrationRunnerModule } from 'src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.module'; | ||
import { WorkspaceSyncMetadataCommandsModule } from 'src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module'; | ||
|
||
@Module({ | ||
imports: [ | ||
TypeOrmModule.forFeature([Workspace], 'core'), | ||
TypeOrmModule.forFeature( | ||
[ObjectMetadataEntity, FieldMetadataEntity], | ||
'metadata', | ||
), | ||
TypeOrmModule.forFeature([FieldMetadataEntity], 'metadata'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: FieldMetadataEntity is imported twice in TypeOrmModule.forFeature(). Remove the duplicate import on line 27. |
||
WorkspaceSyncMetadataCommandsModule, | ||
SearchModule, | ||
WorkspaceMigrationRunnerModule, | ||
WorkspaceMetadataVersionModule, | ||
WorkspaceMigrationModule, | ||
RecordPositionBackfillModule, | ||
FieldMetadataModule, | ||
], | ||
providers: [ | ||
UpgradeTo0_35Command, | ||
PhoneCallingCodeCreateColumnCommand, | ||
WorkspaceMigrationFactory, | ||
RecordPositionBackfillCommand, | ||
ViewGroupNoValueBackfillCommand, | ||
], | ||
}) | ||
export class UpgradeTo0_35CommandModule {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,7 @@ import { Repository } from 'typeorm'; | |
|
||
import { ActiveWorkspacesCommandRunner } from 'src/database/commands/active-workspaces.command'; | ||
import { BaseCommandOptions } from 'src/database/commands/base.command'; | ||
import { PhoneCallingCodeCreateColumnCommand } from 'src/database/commands/upgrade-version/0-40/0-40-phone-calling-code-create-column.command'; | ||
import { PhoneCallingCodeMigrateDataCommand } from 'src/database/commands/upgrade-version/0-40/0-40-phone-calling-code-migrate-data.command'; | ||
import { RecordPositionBackfillCommand } from 'src/database/commands/upgrade-version/0-40/0-40-record-position-backfill.command'; | ||
import { ViewGroupNoValueBackfillCommand } from 'src/database/commands/upgrade-version/0-40/0-40-view-group-no-value-backfill.command'; | ||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; | ||
import { SyncWorkspaceMetadataCommand } from 'src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command'; | ||
|
||
|
@@ -20,11 +17,8 @@ export class UpgradeTo0_40Command extends ActiveWorkspacesCommandRunner { | |
constructor( | ||
@InjectRepository(Workspace, 'core') | ||
protected readonly workspaceRepository: Repository<Workspace>, | ||
private readonly viewGroupNoValueBackfillCommand: ViewGroupNoValueBackfillCommand, | ||
private readonly syncWorkspaceMetadataCommand: SyncWorkspaceMetadataCommand, | ||
private readonly phoneCallingCodeMigrateDataCommand: PhoneCallingCodeMigrateDataCommand, | ||
private readonly phoneCallingCodeCreateColumnCommand: PhoneCallingCodeCreateColumnCommand, | ||
private readonly recordPositionBackfillCommand: RecordPositionBackfillCommand, | ||
) { | ||
super(workspaceRepository); | ||
} | ||
|
@@ -38,30 +32,12 @@ export class UpgradeTo0_40Command extends ActiveWorkspacesCommandRunner { | |
'Running command to upgrade to 0.40: must start with phone calling code otherwise SyncMetadata will fail', | ||
); | ||
|
||
await this.recordPositionBackfillCommand.executeActiveWorkspacesCommand( | ||
passedParam, | ||
options, | ||
workspaceIds, | ||
); | ||
|
||
await this.phoneCallingCodeCreateColumnCommand.executeActiveWorkspacesCommand( | ||
passedParam, | ||
options, | ||
workspaceIds, | ||
); | ||
|
||
await this.phoneCallingCodeMigrateDataCommand.executeActiveWorkspacesCommand( | ||
passedParam, | ||
options, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: log message still references 0.40 but some commands were moved to 0.35 |
||
workspaceIds, | ||
); | ||
|
||
await this.viewGroupNoValueBackfillCommand.executeActiveWorkspacesCommand( | ||
passedParam, | ||
options, | ||
workspaceIds, | ||
); | ||
|
||
await this.syncWorkspaceMetadataCommand.executeActiveWorkspacesCommand( | ||
passedParam, | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Log message incorrectly references version 0.40 instead of 0.35