Skip to content

Commit 505b541

Browse files
committed
Merge branch 'ACP2E-3709' of https://github.com/adobe-commerce-tier-4/magento2ce into PR-03-17-2025
2 parents 52893d4 + 5380121 commit 505b541

File tree

8 files changed

+160
-6
lines changed

8 files changed

+160
-6
lines changed

app/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,7 @@
15791579
<item name="/schema/table/index/column" xsi:type="string">name</item>
15801580
<item name="/schema/table/constraint/column" xsi:type="string">name</item>
15811581
</argument>
1582+
<argument name="typeAttributeName" xsi:type="string">xsi:type</argument>
15821583
</arguments>
15831584
</virtualType>
15841585
<type name="Magento\Framework\Setup\Declaration\Schema\OperationsExecutor">
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
10+
<module name="Magento_TestSetupDeclarationModule11" setup_version="1.0.0" />
11+
</config>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Framework\Component\ComponentRegistrar;
9+
10+
$registrar = new ComponentRegistrar();
11+
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule11') === null) {
12+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule11', __DIR__);
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
10+
<table name="module11_test_main_table" resource="default" engine="innodb" comment="Main Test Table for Module11">
11+
<column xsi:type="int" name="module11_email_contact_id" padding="10" unsigned="true" nullable="false"
12+
identity="true" comment="Entity ID"/>
13+
<column xsi:type="int" name="module11_guest_score" padding="5" unsigned="true" nullable="true"
14+
identity="false" comment="Guest Score"/>
15+
<column xsi:type="int" name="module11_guest_id" padding="10" unsigned="true" nullable="true" identity="false"
16+
comment="Guest ID"/>
17+
<column xsi:type="date" name="module11_created_at" comment="Created At"/>
18+
<constraint xsi:type="primary" referenceId="PRIMARY">
19+
<column name="module11_email_contact_id"/>
20+
</constraint>
21+
<constraint xsi:type="unique" referenceId="MODULE11_INSTALL_UNIQUE_INDEX_1">
22+
<column name="module11_email_contact_id"/>
23+
<column name="module11_guest_id"/>
24+
</constraint>
25+
</table>
26+
</schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
10+
<table name="module11_test_main_table" resource="default" engine="innodb" comment="Main Test Table for Module11">
11+
<column xsi:type="int" name="module11_email_contact_id" padding="10" unsigned="true" nullable="false"
12+
identity="true" comment="Entity ID"/>
13+
<column xsi:type="decimal" name="module11_guest_score" scale="4" precision="20" comment="Guest Score"/>
14+
<column xsi:type="int" name="module11_guest_id" padding="10" unsigned="true" nullable="true" identity="false"
15+
comment="Guest ID"/>
16+
<column xsi:type="date" name="module11_created_at" comment="Created At"/>
17+
<constraint xsi:type="primary" referenceId="PRIMARY">
18+
<column name="module11_email_contact_id"/>
19+
</constraint>
20+
<constraint xsi:type="unique" referenceId="MODULE11_INSTALL_UNIQUE_INDEX_1">
21+
<column name="module11_email_contact_id"/>
22+
<column name="module11_guest_id"/>
23+
</constraint>
24+
</table>
25+
</schema>

dev/tests/setup-integration/testsuite/Magento/Developer/Console/Command/SetupUpgradeTest.php

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -95,6 +95,32 @@ public function testUpgradeWithConverting()
9595
}
9696
}
9797

98+
/**
99+
* Test upgrading a module with a modified db_schema.xml column type.
100+
*
101+
* @moduleName Magento_TestSetupDeclarationModule11
102+
* @throws \Exception
103+
*/
104+
public function testUpgradeWithColumnTypeChange()
105+
{
106+
$moduleName = 'Magento_TestSetupDeclarationModule11';
107+
$this->moduleManager->updateRevision(
108+
$moduleName,
109+
'initial_install',
110+
'db_schema.xml',
111+
'etc'
112+
);
113+
$this->cliCommand->install([$moduleName]);
114+
$this->moduleManager->updateRevision(
115+
$moduleName,
116+
'upgrade_column_type',
117+
'db_schema.xml',
118+
'etc'
119+
);
120+
$this->cliCommand->upgrade();
121+
122+
$this->assertSchemaColumnTypeChange($moduleName);
123+
}
98124
/**
99125
* Convert file content in the DOM document.
100126
*
@@ -170,4 +196,21 @@ private function getSchemaFixturePath(string $moduleName, string $suffix): strin
170196

171197
return $schemaFixturePath;
172198
}
199+
200+
/**
201+
* Assert that the column type has changed as expected.
202+
*
203+
* @param string $moduleName
204+
*/
205+
private function assertSchemaColumnTypeChange(string $moduleName): void
206+
{
207+
$generatedSchema = $this->getGeneratedSchema($moduleName);
208+
$expectedSchema = $this->getSchemaDocument($this->getSchemaFixturePath($moduleName, 'upgrade'));
209+
210+
$this->assertEquals(
211+
$expectedSchema->saveXML(),
212+
$generatedSchema->saveXML(),
213+
"The generated db_schema.xml does not match the expected schema after upgrade."
214+
);
215+
}
173216
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
10+
<table name="module11_test_main_table" resource="default" engine="innodb" comment="Main Test Table for Module11">
11+
<column xsi:type="int" name="module11_email_contact_id" padding="10" unsigned="true" nullable="false"
12+
identity="true" comment="Entity ID"/>
13+
<column xsi:type="decimal" name="module11_guest_score" scale="4" precision="20" comment="Guest Score"/>
14+
<column xsi:type="int" name="module11_guest_id" padding="10" unsigned="true" nullable="true" identity="false"
15+
comment="Guest ID"/>
16+
<column xsi:type="date" name="module11_created_at" comment="Created At"/>
17+
<constraint xsi:type="primary" referenceId="PRIMARY">
18+
<column name="module11_email_contact_id"/>
19+
</constraint>
20+
<constraint xsi:type="unique" referenceId="MODULE11_INSTALL_UNIQUE_INDEX_1">
21+
<column name="module11_email_contact_id"/>
22+
<column name="module11_guest_id"/>
23+
</constraint>
24+
</table>
25+
</schema>

lib/internal/Magento/Framework/Config/Reader/Filesystem.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Framework\Config\Reader;
@@ -81,6 +81,13 @@ class Filesystem implements \Magento\Framework\Config\ReaderInterface
8181
*/
8282
protected $_schemaFile;
8383

84+
/**
85+
* Name of an attribute that stands for data type of node values
86+
*
87+
* @var string|null
88+
*/
89+
private $typeAttributeName;
90+
8491
/**
8592
* Constructor
8693
*
@@ -92,6 +99,7 @@ class Filesystem implements \Magento\Framework\Config\ReaderInterface
9299
* @param array $idAttributes
93100
* @param string $domDocumentClass
94101
* @param string $defaultScope
102+
* @param string|null $typeAttributeName
95103
*/
96104
public function __construct(
97105
\Magento\Framework\Config\FileResolverInterface $fileResolver,
@@ -101,7 +109,8 @@ public function __construct(
101109
$fileName,
102110
$idAttributes = [],
103111
$domDocumentClass = \Magento\Framework\Config\Dom::class,
104-
$defaultScope = 'global'
112+
$defaultScope = 'global',
113+
?string $typeAttributeName = null,
105114
) {
106115
$this->_fileResolver = $fileResolver;
107116
$this->_converter = $converter;
@@ -113,6 +122,7 @@ public function __construct(
113122
? $schemaLocator->getPerFileSchema() : null;
114123
$this->_domDocumentClass = $domDocumentClass;
115124
$this->_defaultScope = $defaultScope;
125+
$this->typeAttributeName = $typeAttributeName;
116126
}
117127

118128
/**
@@ -210,7 +220,7 @@ protected function _createConfigMerger($mergerClass, $initialContents)
210220
$initialContents,
211221
$this->validationState,
212222
$this->_idAttributes,
213-
null,
223+
$this->typeAttributeName,
214224
$this->_perFileSchema
215225
);
216226
if (!$result instanceof \Magento\Framework\Config\Dom) {

0 commit comments

Comments
 (0)