Skip to content

Commit

Permalink
Merge branch 'next-10234/fix-migration' into 'master'
Browse files Browse the repository at this point in the history
NEXT-10234 - Fix migration when german language was deleted

See merge request shopware/6/product/platform!3627
  • Loading branch information
taltholtmann committed Oct 30, 2020
2 parents ba85f00 + 9bab4c5 commit 419b703
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public function update(Connection $connection): void
AND loc.code = \'de-DE\';
');

if (!$germanLanguageId) {
return;
}

$englishLanguageId = $connection->fetchColumn('
SELECT lang.id
FROM language lang
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ public function testMigrateDoesntTouchCustomEntries(): void
static::assertContains('Standardprofil Variantenkonfiguration', $labels);
}

public function testMigrateWithoutGermanLanguage(): void
{
$context = new Context(new SystemSource(), [], Defaults::CURRENCY, [Defaults::LANGUAGE_SYSTEM]);
$this->importExportProfileRepository->create($this->getEnglishData(), $context);

$this->removeLanguageByIsoCode('de-DE');

$this->executeMigration();

$translations = $this->connection->fetchAll('SELECT * FROM import_export_profile_translation');
static::assertCount(6, $translations);

$labels = array_column($translations, 'label');
static::assertNotContains('Standardprofil Variantenkonfiguration', $labels);
}

private function executeMigration(): void
{
$migration = new Migration1599134496FixImportExportProfilesForGermanLanguage();
Expand Down Expand Up @@ -350,4 +366,16 @@ private function getPolishAndEnglishData(string $polishId, string $englishId): a

return $englishData;
}

private function removeLanguageByIsoCode(string $iso): void
{
$this->connection->executeUpdate(
'DELETE `language`
FROM `language`
INNER JOIN `locale` ON `language`.`locale_id` = `locale`.`id`
WHERE `locale`.`code` = :isoCode
',
['isoCode' => $iso]
);
}
}

0 comments on commit 419b703

Please sign in to comment.