Shopware 6.5 - Function or Expression 'variant_listing_config' cannot be used in the CHECK clause



Fehlermeldung

Beim Shopware Update von der Version 6.4 auf 6.5 entsteht folgende Fehlermeldung:

SQLSTATE[HY000]: 
General error: 1901 
Function or expression 'variant_listing_config' cannot be used in the CHECK clause of `variant_listing_config`


Der Fehler entsteht unabhängig von der eingesetzten MariaDB-Version. Betroffen sind daher alle MariaDB Versionen: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11, 11.1, 11.2, 11.3



Problemlösung

Shopware stellt in der Version 6.5.6.0 eine Update-Migration zur Problemlösung bereit. Leider wird das Problem erst in Version 6.5.6.0 gelöst, weshalb das Update zu 6.5 weiterhin fehlschlägt.


Erstellen Sie vor der Ausführung der folgenden MySQL-Befehle einen Server-Snapshot oder ein Server-Backup, um im Fehlerfall zum vorherigen Stand zurückkehren zu können.


Führen Sie folgende Datenbank Befehle über die MySQL CLI oder PhpMyAdmin vor dem Update auf 6.5 durch, um das Problem zu lösen:


# Temporäre Datenbanktabelle erstellen

CREATE TABLE IF NOT EXISTS `product_tmp` (
 `id` BINARY(16) NOT NULL,
 `version_id` BINARY(16) NOT NULL,
 `variant_listing_config` JSON NULL DEFAULT NULL,
 PRIMARY KEY (`id`, `version_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci


# Produkte zur temporären Tabelle hinzufügen, die eine variant_listing_config enthalten

INSERT INTO `product_tmp` (SELECT `id`, `version_id`, `variant_listing_config` FROM `product` WHERE variant_listing_config IS NOT NULL)


# Entfernung der variant_listing_config Spalte der product Tabelle

ALTER TABLE `product` DROP COLUMN `variant_listing_config`


# Erneutes Hinzufügen der variant_listing_config (ohne die Check Clause)

ALTER TABLE `product` ADD COLUMN `variant_listing_config` JSON NULL DEFAULT NULL


# Hinzufügen der ausgelagerten Produkte

UPDATE `product`
SET product.variant_listing_config = (SELECT variant_listing_config FROM product_tmp WHERE product.id = product_tmp.id AND product.version_id = product_tmp.version_id)
WHERE product.variant_listing_config IS NULL AND EXISTS (SELECT variant_listing_config FROM product_tmp WHERE product.id = product_tmp.id AND product.version_id = product_tmp.version_id)
LIMIT 1000


# Entfernung der temporären Datenbanktabelle

DROP TABLE `product_tmp`


Führen Sie im Anschluss das Shopware Update auf 6.5 durch.



Shopware 6.5 Update mit Composer


bin/console system:update:prepare

composer update

bin/console system:update:finish

# Aktualisierung aller Konfigurationsdateien erzwingen
composer recipes:update


Nach Abschluss des Shopware Updates erhalten Sie folgende Ausgabe:


Shopware wurde erfolgreich auf 6.5 aktualisiert.



Häufige Fehlermeldungen


/usr/bin/env: „php": Datei oder Verzeichnis nicht gefunden

Sofern die PHP-Umgebungskonfiguration nicht gefunden werden kann, fehlt die Angabe zur PHP-Binary in dem Bash-Profil. Führen Sie folgenden Befehl aus, um PHP 8.2 als Standard CLI-Version zu hinterlegen:


echo "export PATH=/opt/plesk/php/8.2/bin:$PATH;" >> ~/.bash_profile



Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 315392 bytes)

Sofern das definierte Memory Limit überschritten wird, können Sie die Shopware CLI mit unlimitertem Arbeitsspeicher verwenden.


php -d memory_limit=-1 bin/console system:update:finish




Quellen

Shopware 6.5.6.0 Migration:

https://github.com/shopware/shopware/blob/v6.5.6.0/src/Core/Migration/V6_5/Migration1678197291ConvertVariantListingConfig.php