Skip to content

Commit bc4800a

Browse files
committed
MAGETWO-95595: Index names are ignored by declarative schema
1 parent 46f3f26 commit bc4800a

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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="test_table" resource="default" comment="Test Table">
11+
<column xsi:type="int" name="page_id" nullable="false" unsigned="false" identity="true"/>
12+
<constraint xsi:type="primary" referenceId="PRIMARY">
13+
<column name="page_id"/>
14+
</constraint>
15+
</table>
16+
<table name="test_scope_table" resource="default" comment="Test Scope Table">
17+
<column xsi:type="int" name="scope_id" nullable="false" unsigned="false" identity="true"/>
18+
<constraint xsi:type="primary" referenceId="PRIMARY">
19+
<column name="scope_id"/>
20+
</constraint>
21+
</table>
22+
<table name="dependent" resource="default" comment="Lol">
23+
<column xsi:type="int" name="page_id_on" nullable="false" unsigned="false"/>
24+
<column xsi:type="int" name="scope_id_on" nullable="false" unsigned="false"/>
25+
<!-- Expected name in DB: DEPENDENT_PAGE_ID_ON_TEST_TABLE_PAGE_ID -->
26+
<constraint xsi:type="foreign" referenceId="FOREIGN" table="dependent" column="page_id_on" referenceColumn="page_id"
27+
referenceTable="test_table"/>
28+
<!-- Expected name in DB: DEPENDENT_SCOPE_ID_ON_TEST_SCOPE_TABLE_SCOPE_ID -->
29+
<constraint xsi:type="foreign" referenceId="ScopeIDOnTOScopeTableAndScopeId" table="dependent" column="scope_id_on" referenceColumn="scope_id"
30+
referenceTable="test_scope_table"/>
31+
</table>
32+
</schema>

dev/tests/setup-integration/phpunit.xml.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
<includePath>testsuite</includePath>
3333
<ini name="date.timezone" value="America/Los_Angeles"/>
3434
<ini name="xdebug.max_nesting_level" value="200"/>
35-
<const name="TESTS_INSTALL_CONFIG_FILE" value="{{local_config_file}}"/>
35+
<const name="TESTS_INSTALL_CONFIG_FILE" value="etc/install-config-mysql.php"/>
3636
<const name="TESTS_GLOBAL_CONFIG_FILE" value="etc/config-global.php"/>
3737
<const name="TESTS_GLOBAL_CONFIG_DIR" value="../../../app/etc"/>
38-
<const name="TESTS_CLEANUP" value="{{tests_cleanup}}"/>
39-
<const name="TESTS_MAGENTO_MODE" value="{{app_mode}}"/>
38+
<const name="TESTS_CLEANUP" value="enabled"/>
39+
<const name="TESTS_MAGENTO_MODE" value="developer"/>
4040
<const name="TESTS_ERROR_LOG_LISTENER_LEVEL" value="1"/>
4141
</php>
4242
<!-- Test listeners -->

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,25 @@ public function testTableRename()
296296
->from($this->resourceConnection->getTableName('some_table_renamed'));
297297
self::assertEquals([$dataToMigrate], $adapter->fetchAll($select));
298298
}
299+
300+
/**
301+
* @moduleName Magento_TestSetupDeclarationModule8
302+
*/
303+
public function testForeignKeyReferenceId()
304+
{
305+
$this->cliCommad->install(
306+
['Magento_TestSetupDeclarationModule8']
307+
);
308+
$this->moduleManager->updateRevision(
309+
'Magento_TestSetupDeclarationModule8',
310+
'unpatterned_fk_name',
311+
'db_schema.xml',
312+
'etc'
313+
);
314+
$this->cliCommad->upgrade();
315+
$tableStatements = $this->describeTable->describeShard('default');
316+
$tableSql = $tableStatements['dependent'];
317+
$this->assertRegExp('/CONSTRAINT\s`DEPENDENT_PAGE_ID_ON_TEST_TABLE_PAGE_ID`/', $tableSql);
318+
$this->assertRegExp('/CONSTRAINT\s`DEPENDENT_SCOPE_ID_ON_TEST_SCOPE_TABLE_SCOPE_ID`/', $tableSql);
319+
}
299320
}

0 commit comments

Comments
 (0)