Skip to content

Commit

Permalink
NEXT-29992 - Fix mariadb compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Aug 22, 2023
1 parent bd9d8b9 commit 9cf0a1b
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitlab/stages/11-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Build:
stage: lint
needs: []
services:
- name: mariadb:10.10.5
- name: mariadb:10.10
alias: database
entrypoint: [ "sh", "-c", "docker-entrypoint.sh $MYSQL_CMD" ]
rules:
Expand Down
18 changes: 9 additions & 9 deletions .gitlab/stages/20-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ PHP unit:
needs: []
timeout: 30m
services:
- name: mariadb:10.4.30
- name: mariadb:10.4
alias: database
entrypoint: [ "sh", "-c", "docker-entrypoint.sh $MYSQL_CMD" ]
- name: redis
Expand Down Expand Up @@ -149,7 +149,7 @@ PHP unit:
PHP unit Elasticsearch:
extends: PHP unit
services:
- name: mariadb:10.4.30
- name: mariadb:10.4
alias: database
entrypoint: [ "sh", "-c", "docker-entrypoint.sh $MYSQL_CMD" ]
- name: redis
Expand All @@ -169,7 +169,7 @@ PHP bench:
timeout: 30m
needs: []
services:
- name: mariadb:10.4.30
- name: mariadb:10.4
alias: database
entrypoint: [ "sh", "-c", "docker-entrypoint.sh $MYSQL_CMD" ]
- name: redis
Expand Down Expand Up @@ -268,7 +268,7 @@ PHP migration coverage:
needs: []
timeout: 10m
services:
- name: mariadb:10.4.30
- name: mariadb:10.4
alias: database
entrypoint: [ "sh", "-c", "docker-entrypoint.sh $MYSQL_CMD" ]
variables:
Expand Down Expand Up @@ -343,19 +343,19 @@ PHP Full:
DEV_IMAGE: [ "shopware/development:8.1-composer-2" , "shopware/development:8.2-composer-2"]
FEATURE_ALL: [ "false", "major" ]
MYSQL_CMD: 'mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password --sql-require-primary-key=ON'
- MYSQL_IMAGE: mariadb:10.4.30
- MYSQL_IMAGE: mariadb:10.4
DEV_IMAGE: shopware/development:8.1-composer-2
FEATURE_ALL: 'false'
- MYSQL_IMAGE: mariadb:10.5.21
- MYSQL_IMAGE: mariadb:10.5
DEV_IMAGE: shopware/development:8.1-composer-2
FEATURE_ALL: 'false'
PREFER_LOWEST: 'true'
- MYSQL_IMAGE: mariadb:10.11.4
- MYSQL_IMAGE: mariadb:10.11
DEV_IMAGE: shopware/development:8.1-composer-2
FEATURE_ALL: 'false'
ONLY_CORE: 'true'
TEST_SUITES: "checkout content framework profiling system integration migration"
- MYSQL_IMAGE: mariadb:11.0.2
- MYSQL_IMAGE: mariadb:11.0
DEV_IMAGE: shopware/development:8.1-composer-2
FEATURE_ALL: 'false'
DEPENDENCY_DEV: 'true'
Expand Down Expand Up @@ -421,7 +421,7 @@ PHP Full quarantined:
- !reference [ .rules, long-running ]
parallel:
matrix:
- MYSQL_IMAGE: mariadb:10.4.30
- MYSQL_IMAGE: mariadb:10.4
DEV_IMAGE: shopware/development:8.1-composer-2
FEATURE_ALL: 'false'
ALLOW_FAILURE: 'true'
Expand Down
4 changes: 2 additions & 2 deletions .gitlab/stages/22-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Lighthouse (Administration):
needs: [ Build, 'Jest (Administration)' ]
dependencies: [ Build ]
services:
- name: mariadb:10.4.30
- name: mariadb:10.4
alias: database
variables:
# Use e2e env to deactivate the admin queue worker
Expand Down Expand Up @@ -42,7 +42,7 @@ Lighthouse Server (Storefront):
allow_failure: true
timeout: 1h
services:
- name: mariadb:10.4.30
- name: mariadb:10.4
alias: database
variables:
APP_ENV: prod
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/stages/30-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
needs: [ Build, 'Jest (Administration)' ]
dependencies: [ Build ]
services:
- name: mariadb:10.4.30
- name: mariadb:10.4
alias: database
variables:
APP_ENV: e2e
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/stages/70-visual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Percy:
stage: visual
timeout: 1h
services:
- name: mariadb:10.4.30
- name: mariadb:10.4
alias: database
dependencies: [ Build ]
variables:
Expand Down
8 changes: 8 additions & 0 deletions changelog/_unreleased/2023-08-18-fix-mariadb-compatibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Fix mariadb compatibility
issue: NEXT-29992
---

# Core

* Changed migration `Shopware/Core/Migration/V6_4/Migration1656397126AddMainVariantConfiguration` to drop the foreign key constraint before creating a generated column to bypass a new MariaDB limitation
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ public function update(Connection $connection): void
}

if (!EntityDefinitionQueryHelper::columnExists($connection, 'product', 'variant_listing_config')) {
// Will be dropped anyway in future migrations: Shopware\Core\Migration\V6_5\Migration1678969082DropVariantListingFields
try {
$connection->executeStatement('ALTER TABLE `product` DROP FOREIGN KEY `fk.product.main_variant_id`');
} catch (\Throwable $e) {
// ignore when missing
}

$connection->executeStatement(
'ALTER TABLE `product` ADD COLUMN `variant_listing_config` JSON
GENERATED ALWAYS AS (CASE WHEN `display_parent` IS NOT NULL OR `main_variant_id` IS NOT NULL OR `configurator_group_config` IS NOT NULL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ public function updateDestructive(Connection $connection): void
}

if ($this->columnExists($connection, 'product', 'main_variant_id')) {
// Maybe FK still exists, so we need to drop it first
try {
$connection->executeStatement('ALTER TABLE `product` DROP FOREIGN KEY `fk.product.main_variant_id`');
} catch (\Exception) {
// ignore
}

$connection->executeStatement(
'ALTER TABLE `product` DROP FOREIGN KEY `fk.product.main_variant_id`, DROP COLUMN `main_variant_id`'
'ALTER TABLE `product` DROP COLUMN `main_variant_id`'
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ private function rollbackMigration(): void

if (!EntityDefinitionQueryHelper::columnExists($this->connection, 'product', 'main_variant_id')) {
$this->connection->executeStatement(
'ALTER TABLE `product` ADD COLUMN `main_variant_id` binary(16) DEFAULT NULL,
ADD CONSTRAINT `fk.product.main_variant_id` FOREIGN KEY (`main_variant_id`) REFERENCES `product` (`id`) ON DELETE SET NULL'
'ALTER TABLE `product` ADD COLUMN `main_variant_id` binary(16) DEFAULT NULL'
);
}

Expand Down

0 comments on commit 9cf0a1b

Please sign in to comment.