Skip to content

Commit d76cc54

Browse files
committed
MAGETWO-95595: Index names are ignored by declarative schema
- test disable index
1 parent f7f929f commit d76cc54

File tree

6 files changed

+74
-2
lines changed

6 files changed

+74
-2
lines changed

dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,8 @@
6565
<column name="tinyint"/>
6666
<column name="bigint"/>
6767
</index>
68+
<index referenceId="TEST_TABLE_INDEX_VARCHAR" indexType="btree">
69+
<column name="varchar"/>
70+
</index>
6871
</table>
6972
</schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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">
11+
<!--Columns-->
12+
<column xsi:type="smallint" identity="true" name="smallint" padding="3" nullable="true"/>
13+
<column xsi:type="tinyint" name="tinyint" padding="7" nullable="true" unsigned="false"/>
14+
<column xsi:type="bigint" name="bigint" default="0" padding="13" nullable="true" unsigned="false"/>
15+
<column xsi:type="varchar" name="varchar" length="254" nullable="true"/>
16+
<!--Constraints-->
17+
<constraint xsi:type="unique" referenceId="TEST_TABLE_UNIQUE">
18+
<column name="smallint"/>
19+
<column name="bigint"/>
20+
</constraint>
21+
<!--Indexes-->
22+
<index referenceId="TEST_TABLE_INDEX" indexType="btree">
23+
<column name="tinyint"/>
24+
<column name="bigint"/>
25+
</index>
26+
<index referenceId="TEST_TABLE_INDEX_VARCHAR" indexType="btree">
27+
<column name="varchar"/>
28+
</index>
29+
</table>
30+
</schema>

dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/disable_index_by_external_module/db_schema.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
1010
<table name="test_table" resource="default">
11-
<index referenceId="TEST_TABLE_TINYINT_BIGINT" disabled="1"/>
11+
<index referenceId="TEST_TABLE_INDEX_VARCHAR" disabled="1"/>
1212
</table>
1313
</schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"test_table": {
3+
"index": {
4+
"TEST_TABLE_VARCHAR": true
5+
}
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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_TestSetupDeclarationModule8">
10+
<sequence>
11+
<module name="Magento_TestSetupDeclarationModule1" />
12+
</sequence>
13+
</module>
14+
</config>

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,17 +343,35 @@ public function testDisableIndexByExternalModule()
343343
$this->cliCommad->install(
344344
['Magento_TestSetupDeclarationModule1', 'Magento_TestSetupDeclarationModule8']
345345
);
346+
$this->moduleManager->updateRevision(
347+
'Magento_TestSetupDeclarationModule1',
348+
'index_to_disable',
349+
'db_schema.xml',
350+
'etc'
351+
);
346352
$this->moduleManager->updateRevision(
347353
'Magento_TestSetupDeclarationModule8',
348354
'disable_index_by_external_module',
349355
'db_schema.xml',
350356
'etc'
351357
);
358+
$this->moduleManager->updateRevision(
359+
'Magento_TestSetupDeclarationModule8',
360+
'disable_index_by_external_module',
361+
'db_schema_whitelist.json',
362+
'etc'
363+
);
364+
$this->moduleManager->updateRevision(
365+
'Magento_TestSetupDeclarationModule8',
366+
'disable_index_by_external_module',
367+
'module.xml',
368+
'etc'
369+
);
352370
$this->cliCommad->upgrade();
353371
$tableStatements = $this->describeTable->describeShard('default');
354372
$tableSql = $tableStatements['test_table'];
355373
$this->assertNotRegExp(
356-
'/KEY\s+`TEST_TABLE_TINYINT_BIGINT`\s+\(`tinyint`,`bigint`\)/',
374+
'/KEY\s+`TEST_TABLE_VARCHAR`\s+\(`varchar`\)/',
357375
$tableSql,
358376
'Index is not being disabled by external module'
359377
);

0 commit comments

Comments
 (0)