-
Notifications
You must be signed in to change notification settings - Fork 15
refactor!: migration logging system #31
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
base: feature/migration-logging-refactor
Are you sure you want to change the base?
refactor!: migration logging system #31
Conversation
5812481 to
a1c80c1
Compare
fbe5f78 to
20f1be8
Compare
| [ | ||
| { | ||
| "name": "SwagMigrationAssistant", | ||
| "branch": "feature/migration-logging-refactor", |
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.
fyi: this is needed as long as we haven't released the new SwagMigrationAssistant version
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.
YAML should allow comments, so I would suggest adding something like # Todo: change back to trunk after assistant epic gets merged https://github.com/shopware/shopware/issues/10417
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.
should be switch again before merging this, so I thought a thread is more visible
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.
That also works, just thought this PR is targeting the feature branch in magento and later if the merge that feature branch into trunk again we would need to revert this change 🤷♂️ .
But either way, we just have to keep track of this somehow and a comment would at least be obvious during code review 😅
73382da to
d141656
Compare
d141656 to
c83cec3
Compare
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.
Pull Request Overview
This PR refactors migration connection usage to align with a new API structure and implements a comprehensive migration logging refactor. The main purpose is to modernize the migration context handling by removing nullable connection references and updating the logging system to use a new builder pattern.
Key Changes:
- Migration Context Parameter Reordering: Updated constructor parameter order to prioritize connection, profile, and gateway, removing nullable connection handling
- Logging System Refactor: Replaced direct log instantiation with a builder pattern using
SwagMigrationLogBuilder - Connection Access Simplification: Removed nullable connection checks and simplified connection credential access
Reviewed Changes
Copilot reviewed 93 out of 93 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Multiple test files | Updated MigrationContext constructor calls to match new parameter order |
| Gateway classes | Updated supports() method to use ProfileInterface instead of MigrationContextInterface |
| Converter classes | Replaced direct logging with SwagMigrationLogBuilder pattern and removed nullable connection handling |
| Reader classes | Simplified connection credential access by removing null checks |
| FileHandleErrorLog.php | Refactored logging class to extend new AbstractSwagMigrationLogEntry |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/Profile/Magento2/Converter/Magento2SalesChannelConverter.php
Outdated
Show resolved
Hide resolved
tests/Profile/Magento19/Converter/Magento19CrossSellingConverterTest.php
Show resolved
Hide resolved
MalteJanz
left a comment
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.
I only had a rough look but overall it looks fine to me. I hope we got all logs constructed correctly but otherwise we hopefully will see them as bugs in our developer facing log if we implement the "fixing" correctly (as the fix couldn't be applied for example or still caused a write failure)
| [ | ||
| { | ||
| "name": "SwagMigrationAssistant", | ||
| "branch": "feature/migration-logging-refactor", |
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.
YAML should allow comments, so I would suggest adding something like # Todo: change back to trunk after assistant epic gets merged https://github.com/shopware/shopware/issues/10417
| $this->loggingService->addLogForEach( | ||
| $fields, | ||
| fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) | ||
| ->withEntityName(CategoryDefinition::ENTITY_NAME) | ||
| ->withFieldSourcePath($key) | ||
| ->withSourceData($data) | ||
| ->build(EmptyNecessaryFieldRunLog::class) |
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.
I guess this would produce duplicated logs as well with your new validation right?
shopware/SwagMigrationAssistant#51 (comment)
Just something to keep in mind (you can also create a ticket / additional PR for adjusting Magento again, if that's necessary 🙈 )
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.
yep, basically all EmptyNecessaryFieldRunLog Logs are somewhat duplicates
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.
fyi: created a new ticket for checking the compatibility shopware/shopware#12442
| if (!isset($converted['customerGroupId'])) { | ||
| $this->loggingService->addLogEntry( | ||
| new AssociationRequiredMissingLog( | ||
| $this->runId, | ||
| DefaultEntities::CUSTOMER_GROUP, | ||
| 'default_customer_group', | ||
| DefaultEntities::SALES_CHANNEL | ||
| ) | ||
| SwagMigrationLogBuilder::fromMigrationContext($migrationContext) | ||
| ->withEntityName(SalesChannelDefinition::ENTITY_NAME) | ||
| ->withFieldName('customerGroupId') | ||
| ->withFieldSourcePath('group_id') | ||
| ->withSourceData($data) | ||
| ->withConvertedData($converted) | ||
| ->build(AssociationRequiredMissingLog::class) | ||
| ); | ||
|
|
||
| return new ConvertStruct(null, $this->originalData); |
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.
Not really related to your change but something we have to keep in mind as well:
previously we just logged an error and returned an empty ConvertStruct which basically meant this data would be have the convert_failure flag set in the swag_migration_data table and the write step would ignore this entry completely.
But with this new approach we have to rewrite all converters to:
- still log any issues they encounter
- additionally continue and try to extract as much data as possible, so with the later "fixes" we get a complete entity again
This also has another side effect:
- since we log each error individually the attached
convertedDatacan still evolve and change to include more in a later log. So maybe it's not that useful in the end, we have to evaluate that. Alternative would be just linking to the actual data (swag_migration_data)
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.
Maybe this will also be something we uncover during our backend PoC / prototype and have to deal with👀
| ->withEntityName(CustomerDefinition::ENTITY_NAME) | ||
| ->withFieldName('password_hash') |
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.
Isn't the field just called password in SW6?
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.
yeah, it is 🙈
part of #11883