Skip to content

Commit a3d90ee

Browse files
author
Joan He
committed
Merge remote-tracking branch 'trigger/MC-15292' into 2.3-develop-pr
2 parents a4039fe + 11c681e commit a3d90ee

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_TestSetupDeclarationModule1"/>
10+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
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="reference_table" disabled="true"/>
11+
</schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_TestSetupDeclarationModule3"/>
10+
</config>

dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,45 @@ public function testInstallationWithDroppingTables()
249249
self::assertEquals($this->getData(), $shardData);
250250
}
251251

252+
/**
253+
* @moduleName Magento_TestSetupDeclarationModule1
254+
* @moduleName Magento_TestSetupDeclarationModule3
255+
*/
256+
public function testInstallationWithDroppingTablesFromSecondaryModule()
257+
{
258+
$modules = [
259+
'Magento_TestSetupDeclarationModule1',
260+
'Magento_TestSetupDeclarationModule3',
261+
];
262+
263+
$this->moduleManager->updateRevision(
264+
'Magento_TestSetupDeclarationModule3',
265+
'drop_table_with_external_dependency',
266+
'db_schema.xml',
267+
'etc'
268+
);
269+
270+
foreach ($modules as $moduleName) {
271+
$this->moduleManager->updateRevision(
272+
$moduleName,
273+
'without_setup_version',
274+
'module.xml',
275+
'etc'
276+
);
277+
}
278+
279+
try {
280+
$this->cliCommand->install($modules);
281+
} catch (\Exception $e) {
282+
$installException = $e->getPrevious();
283+
self::assertSame(1, $installException->getCode());
284+
self::assertContains(
285+
'The reference table named "reference_table" is disabled',
286+
$installException->getMessage()
287+
);
288+
}
289+
}
290+
252291
/**
253292
* @moduleName Magento_TestSetupDeclarationModule1
254293
* @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/declarative_installer/rollback.php

lib/internal/Magento/Framework/Setup/Declaration/Schema/Declaration/SchemaBuilder.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ private function processConstraints(array $tableData, string $resource, Schema $
350350
if ($constraintData['type'] === 'foreign') {
351351
$constraintData['column'] = $this->getColumnByName($constraintData['column'], $table);
352352
$referenceTableData = $this->tablesData[$constraintData['referenceTable']];
353+
354+
if ($this->isDisabled($referenceTableData)) {
355+
throw new \LogicException(
356+
sprintf('The reference table named "%s" is disabled', $referenceTableData['name'])
357+
);
358+
}
359+
353360
//If we are referenced to the same table we need to specify it
354361
//Get table name from resource connection regarding prefix settings
355362
$refTableName = $this->resourceConnection->getTableName($referenceTableData['name']);

0 commit comments

Comments
 (0)