Bei der Durchführung einer Migration bzw. eines Updates von Shopware Version 5.4.6 zu 5.6.9 bin ich über verschiedene Fehler in Shopware SQL-Migrationsskripten (Migrations_Migration Classes) gestolpert. …
@Moritz_Naczenski : Hier die korrigierten Dateien, gerne zur internen Weitergabe / Prüfung. (Unterschiede? → vgl. zu Diff mit aktuellen Daten im Git). Gggf. könnt ihr die fehlerhaften Migrationsklassen damit entsprechend updaten/optimieren… :
1459-change-shipping-costs-configs.php
<?php
/**
* Shopware 5
* Copyright (c) shopware AG
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* "Shopware" is a registered trademark of shopware AG.
* The licensing of the program under the AGPLv3 does not imply a
* trademark license. Therefore any rights, title and interest in
* our trademarks remain entirely with us.
*/
class Migrations_Migration1459 extends Shopware\Components\Migrations\AbstractMigration
{
public function up($modus)
{
$options = [
'editable' => false,
'forceSelection' => true,
'translateUsingSnippets' => true,
'namespace' => 'backend/application/main',
'store' => [
[
0,
[
'snippet' => 'shipping_calculations_not_show',
'en_GB' => 'No',
'de_DE' => 'Nein'
],
],
[
1,
[
'snippet' => 'shipping_calculations_show_folded',
'en_GB' => 'Collapsed',
'de_DE' => 'Eingeklappt'
]
],
[
2,
[
'snippet' => 'shipping_calculations_show_expanded',
'en_GB' => 'Expanded',
'de_DE' => 'Ausgeklappt'
]
]
]
];
$sql = <<<'SQL'
SET @parent = (SELECT id FROM s_core_config_forms WHERE name = 'Frontend79' LIMIT 1);
SET @elementId = (SELECT id FROM `s_core_config_elements` WHERE `name` = 'basketShowCalculation' and form_id=@parent LIMIT 1);
SET @value = (SELECT value FROM `s_core_config_values` WHERE `element_id` = @elementId);
UPDATE `s_core_config_elements` set `type`='select', `position`=5, options='%s', `value`='i:1;', label='Versandkostenberechnung im Warenkorb anzeigen' where id=@elementId;
UPDATE `s_core_config_element_translations` set `label`='Show shipping costs calculation in shopping cart' where element_id=@elementId;
UPDATE `s_core_config_values` SET value = 'i:0;' WHERE `element_id` = @elementId;
SQL;
$this->addSql(sprintf($sql, serialize($options)));
}
}
1607-add-voucher-checkout-configs.php
<?php
/**
* Shopware 5
* Copyright (c) shopware AG
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* "Shopware" is a registered trademark of shopware AG.
* The licensing of the program under the AGPLv3 does not imply a
* trademark license. Therefore any rights, title and interest in
* our trademarks remain entirely with us.
*/
class Migrations_Migration1607 extends Shopware\Components\Migrations\AbstractMigration
{
public function up($modus)
{
$options = [
'editable' => false,
'forceSelection' => true,
'translateUsingSnippets' => true,
'namespace' => 'backend/application/main',
'store' => [
[
0,
[
'snippet' => 'voucher_mode_not_show',
'en_GB' => 'No',
'de_DE' => 'Nein'
],
],
[
1,
[
'snippet' => 'voucher_mode_show_folded',
'en_GB' => 'Collapsed',
'de_DE' => 'Eingeklappt'
]
],
[
2,
[
'snippet' => 'voucher_mode_show_expanded',
'en_GB' => 'Expanded',
'de_DE' => 'Ausgeklappt'
]
]
]
];
$sql = <<<'SQL'
SET @parent = (SELECT id FROM s_core_config_forms WHERE name = 'Checkout' LIMIT 1);
INSERT IGNORE INTO `s_core_config_elements` (`id`, `form_id`, `name`, `value`, `label`, `description`, `type`, `required`, `position`, `scope`, `options`) VALUES
(NULL, @parent, 'showVoucherModeForCheckout', 'i:2;', 'Gutscheinfeld im Bestellabschluss anzeigen', NULL, 'select', 0, 0, 0, '%s');
SET @voucherModeElementId = (SELECT id FROM `s_core_config_elements` WHERE `name` = 'showVoucherModeForCheckout' LIMIT 1);
INSERT IGNORE INTO `s_core_config_element_translations` (`element_id`, `locale_id`, `label`)
VALUES (@voucherModeElementId, '2', 'Display voucher field on checkout page');
SET @commentArticleElementId = (SELECT id FROM `s_core_config_elements` WHERE `name` = 'commentVoucherArticle');
UPDATE `s_core_config_elements` SET `description` = 'Artikel hinzufügen, Kommentarfunktion', name = 'commentArticle' WHERE id = @commentArticleElementId;
UPDATE `s_core_config_element_translations` SET description = 'Add product, comment function' WHERE element_id = @commentArticleElementId;
SQL;
$this->addSql(sprintf($sql, serialize($options)));
if ($modus === self::MODUS_UPDATE) {
$sql = <<<'SQL'
INSERT INTO `s_core_config_values` (`element_id`, `shop_id`, `value`)
SELECT @voucherModeElementId, `id`, 'i:0;' FROM s_core_shops
WHERE id NOT IN (SELECT `shop_id` FROM `s_core_config_values` WHERE `element_id` = @voucherModeElementId);
DELETE FROM `s_core_config_values`
WHERE `element_id` = @voucherModeElementId &&
(SELECT value FROM (SELECT * FROM `s_core_config_values`) AS scoreconfigsub WHERE `element_id` = @commentArticleElementId) = 'b:1;';
SQL;
$this->addSql($sql);
}
}
}
1627-add-foreign-key-for-s_order_details.php
<?php
/**
* Shopware 5
* Copyright (c) shopware AG
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* "Shopware" is a registered trademark of shopware AG.
* The licensing of the program under the AGPLv3 does not imply a
* trademark license. Therefore any rights, title and interest in
* our trademarks remain entirely with us.
*/
class Migrations_Migration1627 extends Shopware\Components\Migrations\AbstractMigration
{
public function up($modus)
{
$this->addSql('ALTER TABLE `s_order_details` ADD FOREIGN KEY (`orderID`) REFERENCES `s_order` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT');
}
}
1442-add-meta-description-config.php
<?php
/**
* Shopware 5
* Copyright (c) shopware AG
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* "Shopware" is a registered trademark of shopware AG.
* The licensing of the program under the AGPLv3 does not imply a
* trademark license. Therefore any rights, title and interest in
* our trademarks remain entirely with us.
*/
class Migrations_Migration1442 extends Shopware\Components\Migrations\AbstractMigration
{
public function up($modus)
{
$sql = <<<'EOD'
SET @formId = (SELECT id FROM s_core_config_forms WHERE name = "Frontend100");
INSERT IGNORE INTO `s_core_config_elements`
(`form_id`, `name`, `value`, `label`, `description`, `type`, `required`, `position`, `scope`, `options`)
VALUES
(@formId, 'metaDescriptionLength', 's:3:"150";', 'Maximal erlaubte Länge der Meta Description', '', 'number', 0, 0, 0, NULL);
EOD;
$this->addSql($sql);
$sql = <<<'EOD'
SET @elementId = LAST_INSERT_ID();
INSERT IGNORE INTO `s_core_config_element_translations` (`element_id`, `locale_id`, `label`, `description`)
VALUES (@elementId, 2, 'Maximum allowed length of the meta description', 'Maximum allowed length of the meta description');
EOD;
$this->addSql($sql);
}
}
1434-add-href-default-selection.php
<?php
/**
* Shopware 5
* Copyright (c) shopware AG
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* "Shopware" is a registered trademark of shopware AG.
* The licensing of the program under the AGPLv3 does not imply a
* trademark license. Therefore any rights, title and interest in
* our trademarks remain entirely with us.
*/
class Migrations_Migration1434 extends Shopware\Components\Migrations\AbstractMigration
{
public function up($modus)
{
$settings = [
'valueField' => 'id',
'displayValue' => 'name',
'store' => 'base.ShopLanguage',
'queryMode' => 'remote',
];
$sql = <<<'EOD'
SET @formId = (SELECT id FROM s_core_config_forms WHERE name = "Frontend100");
INSERT IGNORE INTO `s_core_config_elements`
(`form_id`, `name`, `value`, `label`, `description`, `type`, `required`, `position`, `scope`, `options`)
VALUES
(@formId, 'hrefLangDefaultShop', 's:0:"";', 'href-lang Standardsprache', 'Gibt für diesen Shop "x-default" im href-lang-Tag aus und definiert damit die Sprache dieses Shops als Standardsprache.', 'combo', 0, 0, 0, '%s');
EOD;
$this->addSql(sprintf($sql, serialize($settings)));
$sql = <<<'EOD'
SET @elementId = LAST_INSERT_ID();
INSERT IGNORE INTO `s_core_config_element_translations` (`element_id`, `locale_id`, `label`, `description`)
VALUES (@elementId, 2, 'Default href-lang', 'The selected shop will be shown as "x-default" in the href-lang tag, therefore using this shops language as default.');
EOD;
$this->addSql($sql);
}
}