Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 16.0.0
- [BREAKING] [#38](https://github.com/shopware/SwagMigrationAssistant/pull/38) feat!: add migration logging required fields
- [BREAKING] [#40](https://github.com/shopware/SwagMigrationAssistant/pull/40) refactor!: add migration logging optional fields
- [BREAKING] [#43](https://github.com/shopware/SwagMigrationAssistant/pull/43) refactor!: migration connection usage

# 15.0.3
- Fixed translations of error groups missing details like the entity
- Fixed handling of customers without default payment method in SW6.7 migrations
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG_de-DE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 16.0.0
- [BREAKING] [#38](https://github.com/shopware/SwagMigrationAssistant/pull/38) feat!: Erforderliche Felder für Migrationsprotokollierung hinzufügen
- [BREAKING] [#40](https://github.com/shopware/SwagMigrationAssistant/pull/40) refactor!: Optionale Felder für Migrationsprotokollierung hinzufügen
- [BREAKING] [#43](https://github.com/shopware/SwagMigrationAssistant/pull/43) refactor!: Nutzung der Migrationsverbindung

# 15.0.3
- Übersetzungen von Fehlergruppen behoben, welche Details wie den Entitätsnamen nicht darstellten
- Fehler bei Kunden ohne Standardzahlungsmethode in SW6.7 Migrationen behoben
Expand Down
69 changes: 69 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,72 @@
# 16.0.0

- [BREAKING] [#38](https://github.com/shopware/SwagMigrationAssistant/pull/38) - feat!: add migration logging required fields
- [BREAKING] Truncated database entries of `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754896654TruncateMigrationLogs`
- [BREAKING] Deleted columns `title`, `description`, `paramenters`, `title_snippet`, `description_snippet`, `entity` and `source_id` from `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754897550AddRequiredFieldsToMigrationLogs`
- [BREAKING] Removed fields `title`, `description`, `parameters`, `title_snippet`, `description_snippet`, `entity` and `source_id` from log definition `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingDefinition`
- [BREAKING] Removed properties `title`, `description`, `parameters`, `titleSnippet`, `descriptionSnippet`, `entity` and `sourceId` from log entity `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingEntity`
- [BREAKING] Removed aggregations of `titleSnippet`, `entity` and `level` in `SwagMigrationAssistant\Migration\History\HistoryService`
- [BREAKING] Updated all log implementations in `SwagMigrationAssistant\Migration\Logging\Log\*` and `SwagMigrationAssistant\Profile\**\Logging\*`:
- deleted methods `getTitle()`, `getTitleSnippet()`, `getDescription()`, `getDescriptionSnippet()`, `getParameters()`, `getSourceId()`
- add method `isUserFixable()`
- Added columns `profile_name`, `gateway_name` and `user_fixable` to `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754897550AddRequiredFieldsToMigrationLogs`
- Added fields `profile_name`, `gateway_name` and `user_fixable` to log definition `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingDefinition`
- Added properties `profileName`, `gatewayName` and `userFixable` to log entity `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingEntity`

- [BREAKING] [#40](https://github.com/shopware/SwagMigrationAssistant/pull/40) - refactor!: add migration logging optional fields
- [BREAKING] Replaced `SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntity` with `SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry`
- [BREAKING] Replaced `SwagMigrationAssistant\Migration\Logging\Log\LogEntryInterface` with `SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogEntry`
- [BREAKING] Updated all log implementations in `SwagMigrationAssistant\Migration\Logging\Log\*` and `SwagMigrationAssistant\Profile\**\Logging\*`:
- extend `SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry` instead of `SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntity`
- implement `SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogEntry` instead of `SwagMigrationAssistant\Migration\Logging\Log\LogEntryInterface`
- mark class readonly
- [BREAKING] Renamed log classes to include `Log` suffix
- `SwagMigrationAssistant\Migration\Logging\LogCannotConvertChildEntity`,
- `SwagMigrationAssistant\Migration\Logging\LogCannotConvertEntity`,
- `SwagMigrationAssistant\Migration\Logging\LogDocumentTypeNotSupported`,
- `SwagMigrationAssistant\Migration\Logging\LogInvalidUnserializedData`,
- `SwagMigrationAssistant\Migration\Logging\LogInvalidUnserializedData`,
- `SwagMigrationAssistant\Migration\Logging\LogRunAbortedAutomatically`
- `SwagMigrationAssistant\Migration\Logging\LogUnsupportedObjectType`
- [BREAKING] Change method `addLogEntry()` of `SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface` and implementation `LoggingService` to require `SwagMigrationLogEntry` as parameter instead of `LogEntryInterface`
- Created `SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder` to build log entries of type `SwagMigrationLogEntry`
- Added columns to `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754897550AddRequiredFieldsToMigrationLogs`:
- `entity_name`
- `field_name`
- `field_source_path`
- `source_data`
- `converted_data`
- `used_mapping`
- `exception_message`
- `exception_trace`
- Added fields to `swag_migration_logging` to log definition `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingDefinition`:
- `entity_name`
- `field_name`
- `field_source_path`
- `source_data`
- `converted_data`
- `used_mapping`
- `exception_message`
- `exception_trace`
- Added properties and methods to log entity `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingEntity`:
- `entityName` and `getEntityName()`
- `fieldName` and `getFieldName()`
- `fieldSourcePath` and `getFieldSourcePath()`
- `sourceData` and `getSourceData()`
- `convertedData` and `getConvertedData()`
- `usedMapping` and `getUsedMapping()`
- `exceptionMessage` and `getExceptionMessage()`
- `exceptionTrace` and `getExceptionTrace()`

- [BREAKING] [#43](https://github.com/shopware/SwagMigrationAssistant/pull/43) refactor!: migration connection usage
- Changed signature of method `supports()` in `SwagMigrationAssistant\Migration\Gateway\GatewayInterface` to require `ProfileInterface` as parameter instead of `MigrationContextInterface`
- Changed signature of method `getGateways()` in `SwagMigrationAssistant\Migration\Gateway\GatewayRegistryInterface` to require `ProfileInterface` as parameter instead of `MigrationContextInterface`
- Changed signature of method `getGateways()` in `SwagMigrationAssistant\Migration\Gateway\GatewayRegistry` to require `ProfileInterface` as parameter instead of `MigrationContextInterface`
- Changed signature of constructor method of `SwagMigrationAssistant\Migration\MigrationContext` to require `SwagMigrationConnectionEntity` and additional optional parameter of `ProfileInterface` with default value `null`
- Added methods `setProfile()`, `getGateway()`, `setGateway()` and `setConnection()` to `SwagMigrationAssistant\Migration\MigrationContextInterface`
- Added methods `setProfile()`, `getGateway()`, `setGateway()` and `setConnection()` to `SwagMigrationAssistant\Migration\MigrationContext`
- Added null checks to methods `getProfile()` and `getGateway()` in `SwagMigrationAssistant\Migration\MigrationContext` to ensure that a profile and gateway is set before usage

# 14.0.0
- [BREAKING] MIG-1053 - Removed ability to set the `verify` flag for the guzzle API client. This is now always true by default.
- [BREAKING] MIG-1053 - Refactored both Shopware 5 and Shopware 6 EnvironmentReader classes to provide more information about exceptions.
Expand Down
10 changes: 0 additions & 10 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ parameters:
paths:
- tests/**/*Test.php

- # TODO remove with #11883
message: '#Strict comparison using === between SwagMigrationAssistant\\Migration\\Connection\\SwagMigrationConnectionEntity and null will always evaluate to false\.#'
paths:
- **/*.php

- # TODO remove with #11883
message: '#Strict comparison using !== between SwagMigrationAssistant\\Migration\\Connection\\SwagMigrationConnectionEntity and null will always evaluate to true\.#'
paths:
- **/*.php

rules:
# Shopware core rules
- Shopware\Core\DevOps\StaticAnalyze\PHPStan\Rules\Deprecation\DeprecatedMethodsThrowDeprecationRule
Expand Down
8 changes: 4 additions & 4 deletions src/Controller/StatusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public function getProfileInformation(Request $request): Response
return new Response();
}

$migrationContext = $this->migrationContextFactory->createByProfileName($profileName);
$gateways = $this->gatewayRegistry->getGateways($migrationContext);
$profile = $this->profileRegistry->getProfile($profileName);
$gateways = $this->gatewayRegistry->getGateways($profile);

$currentGateway = null;
foreach ($gateways as $gateway) {
Expand Down Expand Up @@ -151,8 +151,8 @@ public function getGateways(Request $request): JsonResponse
throw RoutingException::missingRequestParameter('profileName');
}

$migrationContext = $this->migrationContextFactory->createByProfileName($profileName);
$gateways = $this->gatewayRegistry->getGateways($migrationContext);
$profile = $this->profileRegistry->getProfile($profileName);
$gateways = $this->gatewayRegistry->getGateways($profile);

$gatewayNames = [];
foreach ($gateways as $gateway) {
Expand Down
3 changes: 2 additions & 1 deletion src/Migration/Converter/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ protected function updateMainMapping(MigrationContextInterface $migrationContext

$dataSet = $migrationContext->getDataSet();
$connection = $migrationContext->getConnection();
if ($dataSet === null || $connection === null) {

if ($dataSet === null) {
return;
}

Expand Down
7 changes: 1 addition & 6 deletions src/Migration/Converter/ConverterRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public function getConverter(MigrationContextInterface $migrationContext): Conve
}
}

$connection = $migrationContext->getConnection();
if ($connection === null) {
throw MigrationException::migrationContextPropertyMissing('Connection');
}

throw MigrationException::converterNotFound($connection->getProfileName());
throw MigrationException::converterNotFound($migrationContext->getProfile()->getName());
}
}
3 changes: 2 additions & 1 deletion src/Migration/Gateway/GatewayInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Shopware\Core\Framework\Log\Package;
use SwagMigrationAssistant\Migration\EnvironmentInformation;
use SwagMigrationAssistant\Migration\MigrationContextInterface;
use SwagMigrationAssistant\Migration\Profile\ProfileInterface;
use SwagMigrationAssistant\Migration\TotalStruct;

#[Package('fundamentals@after-sales')]
Expand All @@ -23,7 +24,7 @@ public function getSnippetName(): string;
/**
* Identifier for a gateway registry
*/
public function supports(MigrationContextInterface $migrationContext): bool;
public function supports(ProfileInterface $profile): bool;

/**
* Reads the given entity type from via context from its connection and returns the data
Expand Down
11 changes: 4 additions & 7 deletions src/Migration/Gateway/GatewayRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Shopware\Core\Framework\Log\Package;
use SwagMigrationAssistant\Exception\MigrationException;
use SwagMigrationAssistant\Migration\MigrationContextInterface;
use SwagMigrationAssistant\Migration\Profile\ProfileInterface;

#[Package('fundamentals@after-sales')]
class GatewayRegistry implements GatewayRegistryInterface
Expand All @@ -24,11 +25,11 @@ public function __construct(private readonly iterable $gateways)
/**
* @return GatewayInterface[]
*/
public function getGateways(MigrationContextInterface $migrationContext): array
public function getGateways(ProfileInterface $profile): array
{
$gateways = [];
foreach ($this->gateways as $gateway) {
if ($gateway->supports($migrationContext)) {
if ($gateway->supports($profile)) {
$gateways[] = $gateway;
}
}
Expand All @@ -39,15 +40,11 @@ public function getGateways(MigrationContextInterface $migrationContext): array
public function getGateway(MigrationContextInterface $migrationContext): GatewayInterface
{
$connection = $migrationContext->getConnection();
if ($connection === null) {
throw MigrationException::migrationContextPropertyMissing('Connection');
}

$profileName = $connection->getProfileName();
$gatewayName = $connection->getGatewayName();

foreach ($this->gateways as $gateway) {
if ($gateway->supports($migrationContext) && $gateway->getName() === $gatewayName) {
if ($gateway->supports($migrationContext->getProfile()) && $gateway->getName() === $gatewayName) {
return $gateway;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Migration/Gateway/GatewayRegistryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

use Shopware\Core\Framework\Log\Package;
use SwagMigrationAssistant\Migration\MigrationContextInterface;
use SwagMigrationAssistant\Migration\Profile\ProfileInterface;

#[Package('fundamentals@after-sales')]
interface GatewayRegistryInterface
{
/**
* @return GatewayInterface[]
*/
public function getGateways(MigrationContextInterface $migrationContext): array;
public function getGateways(ProfileInterface $profile): array;

/**
* Selects the correct gateway by the given migration context
Expand Down
9 changes: 4 additions & 5 deletions src/Migration/Media/MediaFileProcessorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use Shopware\Core\Framework\Log\Package;
use SwagMigrationAssistant\Exception\MigrationException;
use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity;
use SwagMigrationAssistant\Migration\MigrationContextInterface;

#[Package('fundamentals@after-sales')]
Expand All @@ -34,10 +33,10 @@ public function getProcessor(MigrationContextInterface $migrationContext): Media
}

$connection = $migrationContext->getConnection();
if ($connection === null) {
throw MigrationException::entityNotExists(SwagMigrationConnectionEntity::class, $migrationContext->getRunUuid());
}

throw MigrationException::processorNotFound($connection->getProfileName(), $connection->getGatewayName());
throw MigrationException::processorNotFound(
$connection->getProfileName(),
$connection->getGatewayName()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\Log\Package;
use SwagMigrationAssistant\Exception\MigrationException;
use SwagMigrationAssistant\Migration\Data\SwagMigrationDataCollection;
use SwagMigrationAssistant\Migration\Media\SwagMigrationMediaFileCollection;
use SwagMigrationAssistant\Migration\MessageQueue\Message\MigrationProcessMessage;
Expand Down Expand Up @@ -59,10 +58,6 @@ public function process(
MigrationProgress $progress,
): void {
$connection = $migrationContext->getConnection();
if ($connection === null) {
throw MigrationException::noConnectionFound();
}

$this->runService->cleanupMappingChecksums($connection->getId(), $context);

$this->runTransitionService->forceTransitionToRunStep($migrationContext->getRunUuid(), MigrationStep::CLEANUP);
Expand Down
74 changes: 41 additions & 33 deletions src/Migration/MigrationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Struct\Struct;
use SwagMigrationAssistant\Exception\MigrationException;
use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity;
use SwagMigrationAssistant\Migration\DataSelection\DataSet\DataSet;
use SwagMigrationAssistant\Migration\Gateway\GatewayInterface;
Expand All @@ -19,48 +20,55 @@ class MigrationContext extends Struct implements MigrationContextInterface
{
final public const SOURCE_CONTEXT = 'MIGRATION_CONNECTION_CHECK_FOR_RUNNING_MIGRATION';

private ProfileInterface $profile;

private ?SwagMigrationConnectionEntity $connection;

private string $runUuid;
public function __construct(
private SwagMigrationConnectionEntity $connection,
private ?ProfileInterface $profile = null,
private ?GatewayInterface $gateway = null,
private ?DataSet $dataSet = null,
private readonly string $runUuid = '',
private int $offset = 0,
private int $limit = 0,
) {
}

private ?DataSet $dataSet;
public function getProfile(): ProfileInterface
{
if ($this->profile === null) {
throw MigrationException::migrationContextPropertyMissing('profile');
}

private int $offset;
return $this->profile;
}

private int $limit;
public function setProfile(ProfileInterface $profile): void
{
$this->profile = $profile;
}

private GatewayInterface $gateway;
public function getGateway(): GatewayInterface
{
if ($this->gateway === null) {
throw MigrationException::migrationContextPropertyMissing('gateway');
}

public function __construct(
ProfileInterface $profile,
?SwagMigrationConnectionEntity $connection = null,
string $runUuid = '',
?DataSet $dataSet = null,
int $offset = 0,
int $limit = 0,
) {
$this->profile = $profile;
$this->connection = $connection;
$this->runUuid = $runUuid;
$this->dataSet = $dataSet;
$this->offset = $offset;
$this->limit = $limit;
return $this->gateway;
}

public function getProfile(): ProfileInterface
public function setGateway(GatewayInterface $gateway): void
{
return $this->profile;
$this->gateway = $gateway;
}

public function getConnection(): SwagMigrationConnectionEntity
{
\assert($this->connection instanceof SwagMigrationConnectionEntity);

return $this->connection;
}

public function setConnection(SwagMigrationConnectionEntity $connection): void
{
$this->connection = $connection;
}

public function getRunUuid(): string
{
return $this->runUuid;
Expand All @@ -81,18 +89,18 @@ public function getOffset(): int
return $this->offset;
}

public function getLimit(): int
public function setOffset(int $offset): void
{
return $this->limit;
$this->offset = $offset;
}

public function getGateway(): GatewayInterface
public function getLimit(): int
{
return $this->gateway;
return $this->limit;
}

public function setGateway(GatewayInterface $gateway): void
public function setLimit(int $limit): void
{
$this->gateway = $gateway;
$this->limit = $limit;
}
}
Loading
Loading