Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 2 additions & 2 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
}
- name: Import SW5 TestData DB
working-directory: custom/plugins/${{ github.event.repository.name }}/tests
run: mysql -uroot < testData/sw55.sql
run: mysql -uroot < _fixtures/database/sw55.sql
- name: Run PHPUnit
working-directory: custom/plugins/${{ github.event.repository.name }}
run: php -d pcov.enabled=1 -d pcov.directory=${PWD} -d pcov.exclude='~(vendor|tests|node_modules)~' ${GITHUB_WORKSPACE}/vendor/bin/phpunit --configuration phpunit.xml.dist
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
run: |
composer run build:js:admin
cd custom/plugins/${{ github.event.repository.name }}/tests
mysql -uroot < testData/sw55.sql
mysql -uroot < _fixtures/database/sw55.sql
- name: Install playwright
working-directory: custom/plugins/${{ github.event.repository.name }}/tests/acceptance
run: |
Expand Down
199 changes: 0 additions & 199 deletions .gitlab-ci.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .gitlab/install_test_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ function failAssert(bool $condition, string $message) {
echo "SwagMigrationAssistant: found DB host: " . $host . PHP_EOL;
echo "SwagMigrationAssistant: found DB user: " . $user . PHP_EOL;

$testDataPath = $pluginPath . '/tests/testData/sw55.sql';
$testDataPath = $pluginPath . '/tests/_fixtures/database/sw55.sql';
echo "SwagMigrationAssistant: test data path: " . $testDataPath . PHP_EOL;
failAssert(file_exists($testDataPath), 'test data sql file does not exists');

// import test data
// mysql -u"$user" -p"$password" --host "$host" < tests/testData/sw55.sql
// mysql -u"$user" -p"$password" --host "$host" < tests/_fixtures/database/sw55.sql
$cmd = sprintf('mysql -u"%s" -p"%s" --host "%s" < %s', $user, $password, $host, $testDataPath);
$output = [];
$resultCode = 0;
Expand Down
2 changes: 1 addition & 1 deletion bin/install-5-test-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ echo "MySQL host: $host"
echo "MySQL user: $user"

# import test data
mysql -u"$user" -p"$password" --host "$host" < tests/testData/sw55.sql
mysql -u"$user" -p"$password" --host "$host" < tests/_fixtures/database/sw55.sql
1 change: 0 additions & 1 deletion src/Controller/StatusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ public function resetChecksums(Request $request, Context $context): Response
throw MigrationException::noConnectionFound();
}

// ToDo: MIG-965 - Check how we could put this into the MQ
$this->runService->cleanupMappingChecksums($connectionId, $context);

return new Response();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,35 @@
use Shopware\Core\Framework\Migration\MigrationStep;

#[Package('fundamentals@after-sales')]
class Migration1754897550AddRequiredFieldsToMigrationLogs extends MigrationStep
class Migration1754897550AddFieldsToMigrationLogs extends MigrationStep
{
public const MIGRATION_LOGGING_TABLE = 'swag_migration_logging';

public const REQUIRED_FIELDS = [
'id' => 'BINARY(16) NOT NULL',
'run_id' => null,
'level' => null,
'code' => null,
'profile_name' => 'VARCHAR(255) NOT NULL',
'gateway_name' => 'VARCHAR(255) NOT NULL',
'run_id' => 'BINARY(16) NULL',
'profile_name' => 'VARCHAR(64) NOT NULL',
'gateway_name' => 'VARCHAR(64) NOT NULL',
'level' => 'VARCHAR(64) NOT NULL',
'code' => 'VARCHAR(255) NOT NULL',
'user_fixable' => 'TINYINT(1) NOT NULL DEFAULT 0',
'auto_increment' => null,
'created_at' => null,
'updated_at' => null,
];

public const OPTIONAL_FIELDS = [
'entity_name' => 'VARCHAR(64) NULL',
'field_name' => 'VARCHAR(64) NULL',
'field_source_path' => 'VARCHAR(255) NULL',
'source_data' => 'JSON NULL',
'converted_data' => 'JSON NULL',
'used_mapping' => 'JSON NULL',
'exception_message' => 'VARCHAR(255) NULL',
'exception_trace' => 'JSON NULL',
];

public const SYSTEM_FIELDS = [
'auto_increment' => 'BIGINT UNSIGNED AUTO_INCREMENT UNIQUE',
'created_at' => 'DATETIME(3) NOT NULL',
'updated_at' => 'DATETIME(3) NULL',
];

public function getCreationTimestamp(): int
Expand All @@ -53,7 +67,7 @@ public function update(Connection $connection): void
$this->dropConstraintIfExists($connection, 'json.swag_migration_logging.log_entry');

$this->dropObsoleteColumns($connection, $schemaManager);
$this->addOrModifyRequiredColumns($connection, $schemaManager);
$this->addOrModifyColumns($connection, $schemaManager);
$this->ensureRelations($connection, $schemaManager);
}

Expand All @@ -64,8 +78,14 @@ private function dropObsoleteColumns(Connection $connection, AbstractSchemaManag
{
$columns = $schemaManager->listTableColumns(self::MIGRATION_LOGGING_TABLE);

$allFields = array_merge(
self::REQUIRED_FIELDS,
self::OPTIONAL_FIELDS,
self::SYSTEM_FIELDS
);

foreach ($columns as $column) {
if (!\array_key_exists($column->getName(), self::REQUIRED_FIELDS)) {
if (!\array_key_exists($column->getName(), $allFields)) {
$connection->executeStatement(
\sprintf(
'ALTER TABLE `%s` DROP COLUMN `%s`;',
Expand All @@ -80,15 +100,17 @@ private function dropObsoleteColumns(Connection $connection, AbstractSchemaManag
/**
* @param AbstractSchemaManager<MySQLPlatform> $schemaManager
*/
private function addOrModifyRequiredColumns(Connection $connection, AbstractSchemaManager $schemaManager): void
private function addOrModifyColumns(Connection $connection, AbstractSchemaManager $schemaManager): void
{
$columns = $schemaManager->listTableColumns(self::MIGRATION_LOGGING_TABLE);

foreach (self::REQUIRED_FIELDS as $name => $type) {
if ($type === null) {
continue;
}
$orderedFields = array_merge(
self::REQUIRED_FIELDS,
self::OPTIONAL_FIELDS,
self::SYSTEM_FIELDS
);

foreach ($orderedFields as $name => $type) {
if (!isset($columns[$name])) {
$connection->executeStatement(
\sprintf(
Expand Down
1 change: 0 additions & 1 deletion src/DataProvider/Provider/Data/OrderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public function getProvidedData(int $limit, int $offset, Context $context): arra
$row['positionPrice']
);

// ToDo MIG-902: properly migrate this association
if (!empty($row['lineItems'])) {
foreach ($row['lineItems'] as &$lineItem) {
unset($lineItem['promotionId']);
Expand Down
7 changes: 3 additions & 4 deletions src/DataProvider/Provider/Data/ProductProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ public function getProvidedData(int $limit, int $offset, Context $context): arra
'thumbnails',
'thumbnailsRo',
'hasFile',
'userId', // maybe put back in, if we migrate users

'canonicalProductId', // ToDo MIG-900: properly migrate this association in a separate DataSet
'cmsPageId', // ToDo MIG-901: properly migrate this association in a separate DataSet
'userId',
'canonicalProductId',
'cmsPageId',
]);

foreach ($cleanResult as &$product) {
Expand Down
17 changes: 2 additions & 15 deletions src/Migration/Logging/Log/AssociationRequiredMissingLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,11 @@
namespace SwagMigrationAssistant\Migration\Logging\Log;

use Shopware\Core\Framework\Log\Package;
use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry;

#[Package('fundamentals@after-sales')]
class AssociationRequiredMissingLog extends BaseRunLogEntry
readonly class AssociationRequiredMissingLog extends AbstractSwagMigrationLogEntry
{
public function __construct(
string $runId,
string $profileName,
string $gatewayName,
/** @phpstan-ignore property.onlyWritten */
private readonly string $requiredFor,
) {
parent::__construct(
$runId,
$profileName,
$gatewayName,
);
}

public function isUserFixable(): bool
{
return false;
Expand Down
Loading
Loading