Skip to content

Commit d47c991

Browse files
committed
AC-7469:MySQL Support
1 parent f9b3f7c commit d47c991

File tree

10 files changed

+169
-2
lines changed

10 files changed

+169
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
// @codingStandardsIgnoreFile
7+
return [
8+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
9+
`int_auto_increment_with_nullable` int unsigned NOT NULL AUTO_INCREMENT,
10+
`int_disabled_auto_increment` smallint unsigned DEFAULT \'0\',
11+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
12+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3',
13+
'reference_table' => 'CREATE TABLE `reference_table` (
14+
`tinyint_ref` tinyint NOT NULL AUTO_INCREMENT,
15+
`tinyint_without_padding` tinyint NOT NULL DEFAULT \'0\',
16+
`bigint_without_padding` bigint NOT NULL DEFAULT \'0\',
17+
`smallint_without_padding` smallint NOT NULL DEFAULT \'0\',
18+
`integer_without_padding` int NOT NULL DEFAULT \'0\',
19+
`smallint_with_big_padding` smallint NOT NULL DEFAULT \'0\',
20+
`smallint_without_default` smallint DEFAULT NULL,
21+
`int_without_unsigned` int DEFAULT NULL,
22+
`int_unsigned` int unsigned DEFAULT NULL,
23+
`bigint_default_nullable` bigint unsigned DEFAULT \'1\',
24+
`bigint_not_default_not_nullable` bigint unsigned NOT NULL,
25+
`smallint_ref` smallint NOT NULL DEFAULT \'0\',
26+
PRIMARY KEY (`tinyint_ref`,`smallint_ref`),
27+
UNIQUE KEY `REFERENCE_TABLE_SMALLINT_REF` (`smallint_ref`)
28+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3',
29+
'test_table' => 'CREATE TABLE `test_table` (
30+
`smallint` smallint DEFAULT NULL,
31+
`tinyint` tinyint DEFAULT NULL,
32+
`bigint` bigint DEFAULT \'0\',
33+
`float` float(12,10) DEFAULT \'0.0000000000\',
34+
`double` double(245,10) DEFAULT \'11111111.1111110000\',
35+
`decimal` decimal(15,4) DEFAULT \'0.0000\',
36+
`date` date DEFAULT NULL,
37+
`timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
38+
`datetime` datetime DEFAULT \'0000-00-00 00:00:00\',
39+
`longtext` longtext,
40+
`mediumtext` mediumtext,
41+
`varchar` varchar(254) DEFAULT NULL,
42+
`char` char(255) DEFAULT NULL,
43+
`mediumblob` mediumblob,
44+
`blob` blob,
45+
`boolean` tinyint(1) DEFAULT NULL,
46+
`integer_main` int unsigned DEFAULT NULL,
47+
`smallint_main` smallint NOT NULL DEFAULT \'0\',
48+
UNIQUE KEY `TEST_TABLE_SMALLINT_FLOAT` (`smallint`,`float`),
49+
UNIQUE KEY `TEST_TABLE_DOUBLE` (`double`),
50+
KEY `TEST_TABLE_TINYINT_BIGINT` (`tinyint`,`bigint`),
51+
KEY `TEST_TABLE_SMALLINT_MAIN_REFERENCE_TABLE_SMALLINT_REF` (`smallint_main`),
52+
KEY `FK_FB77604C299EB8612D01E4AF8D9931F2` (`integer_main`),
53+
CONSTRAINT `FK_FB77604C299EB8612D01E4AF8D9931F2` FOREIGN KEY (`integer_main`) REFERENCES `auto_increment_test` (`int_auto_increment_with_nullable`) ON DELETE CASCADE,
54+
CONSTRAINT `TEST_TABLE_SMALLINT_MAIN_REFERENCE_TABLE_SMALLINT_REF` FOREIGN KEY (`smallint_main`) REFERENCES `reference_table` (`smallint_ref`) ON DELETE CASCADE,
55+
CONSTRAINT `TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE SET NULL
56+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3',
57+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
// @codingStandardsIgnoreFile
9+
return [
10+
'before' => [
11+
'store' => 'CREATE TABLE `store` (
12+
`store_owner_id` smallint DEFAULT NULL COMMENT \'Store Owner Reference\',
13+
KEY `STORE_STORE_OWNER_ID_STORE_OWNER_OWNER_ID` (`store_owner_id`),
14+
CONSTRAINT `STORE_STORE_OWNER_ID_STORE_OWNER_OWNER_ID` FOREIGN KEY (`store_owner_id`) REFERENCES `store_owner` (`owner_id`) ON DELETE SET NULL
15+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3',
16+
'store_owner' => 'CREATE TABLE `store_owner` (
17+
`owner_id` smallint NOT NULL AUTO_INCREMENT,
18+
`store_owner_name` varchar(255) DEFAULT NULL COMMENT \'Store Owner Name\',
19+
PRIMARY KEY (`owner_id`)
20+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT=\'Store owner information\''
21+
],
22+
'after' => [
23+
'store' => 'CREATE TABLE `store` (
24+
`store_owner` varchar(255) DEFAULT NULL COMMENT \'Store Owner Name\'
25+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3'
26+
]
27+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
return [
7+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
8+
`int_auto_increment_with_nullable` int unsigned NOT NULL AUTO_INCREMENT,
9+
`int_disabled_auto_increment` smallint unsigned DEFAULT \'0\',
10+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
11+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3'
12+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
return [
9+
'before' => 'CREATE TABLE `some_table` (
10+
`some_column` varchar(255) DEFAULT NULL COMMENT \'Some Column Name\'
11+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3',
12+
'after' => 'CREATE TABLE `some_table_renamed` (
13+
`some_column` varchar(255) DEFAULT NULL COMMENT \'Some Column Name\'
14+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3',
15+
];
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
return [
7+
'test_table_one' => 'CREATE TABLE `test_table_one` (
8+
`smallint` smallint NOT NULL AUTO_INCREMENT,
9+
`varchar` varchar(254) DEFAULT NULL,
10+
PRIMARY KEY (`smallint`)
11+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3',
12+
'test_table_two' => 'CREATE TABLE `test_table_two` (
13+
`smallint` smallint NOT NULL AUTO_INCREMENT,
14+
`varchar` varchar(254) DEFAULT NULL,
15+
PRIMARY KEY (`smallint`)
16+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3',
17+
'reference_table' => 'CREATE TABLE `reference_table` (
18+
`tinyint_ref` tinyint NOT NULL AUTO_INCREMENT,
19+
`tinyint_without_padding` tinyint NOT NULL DEFAULT \'0\',
20+
`bigint_without_padding` bigint NOT NULL DEFAULT \'0\',
21+
`smallint_without_padding` smallint NOT NULL DEFAULT \'0\',
22+
`integer_without_padding` int NOT NULL DEFAULT \'0\',
23+
`smallint_with_big_padding` smallint NOT NULL DEFAULT \'0\',
24+
`smallint_without_default` smallint DEFAULT NULL,
25+
`int_without_unsigned` int DEFAULT NULL,
26+
`int_unsigned` int unsigned DEFAULT NULL,
27+
`bigint_default_nullable` bigint unsigned DEFAULT \'1\',
28+
`bigint_not_default_not_nullable` bigint unsigned NOT NULL,
29+
PRIMARY KEY (`tinyint_ref`)
30+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3',
31+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
32+
`int_auto_increment_with_nullable` int unsigned NOT NULL AUTO_INCREMENT,
33+
`int_disabled_auto_increment` smallint unsigned DEFAULT \'0\',
34+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
35+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3'
36+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
return [
9+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
10+
`int_auto_increment_with_nullable` int unsigned NOT NULL AUTO_INCREMENT,
11+
`int_disabled_auto_increment` smallint unsigned DEFAULT \'0\',
12+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
13+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3'
14+
];

dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class DataProviderFromFile
2828
public const POSSIBLE_SUFFIXES = [
2929
SqlVersionProvider::MYSQL_8_0_VERSION => 'mysql8',
3030
SqlVersionProvider::MARIA_DB_10_4_VERSION => 'mariadb10',
31-
SqlVersionProvider::MARIA_DB_10_6_VERSION => 'mariadb106'
31+
SqlVersionProvider::MARIA_DB_10_6_VERSION => 'mariadb106',
32+
SqlVersionProvider::MYSQL_8_0_29_VERSION => 'mysql829'
3233
];
3334

3435
/**

dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/SetupTestCase.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ private function getDbKey(): string
107107

108108
$this->dbKey = DataProviderFromFile::FALLBACK_VALUE;
109109
foreach (DataProviderFromFile::POSSIBLE_SUFFIXES as $possibleVersion => $suffix) {
110-
if (strpos($this->getDatabaseVersion(), (string)$possibleVersion) !== false) {
110+
if ($this->sqlVersionProvider->isMysqlGte8029()) {
111+
$this->dbKey = DataProviderFromFile::POSSIBLE_SUFFIXES[SqlVersionProvider::MYSQL_8_0_29_VERSION];
112+
break;
113+
} elseif (strpos($this->getDatabaseVersion(), (string)$possibleVersion) !== false) {
111114
$this->dbKey = $suffix;
112115
break;
113116
}

lib/internal/Magento/Framework/DB/Adapter/SqlVersionProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class SqlVersionProvider
2929

3030
public const MARIA_DB_10_6_VERSION = '10.6.';
3131

32+
public const MYSQL_8_0_29_VERSION = '8.0.29';
33+
3234
/**#@-*/
3335

3436
/**

0 commit comments

Comments
 (0)