Skip to content

Commit 572088d

Browse files
committed
Merge branch 'MAGETWO-88047' of github.com:magento-trigger/magento2ce into MAGETWO-88054
2 parents 24ad802 + 835796e commit 572088d

File tree

32 files changed

+1180
-24
lines changed

32 files changed

+1180
-24
lines changed

app/code/Magento/Developer/Console/Command/patch_template.php.dist

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace %moduleName%\Setup\Patch\%patchType%;
88

9-
use Magento\Framework\Setup\Patch\PatchVersionInterface;
109
use Magento\Framework\Setup\Patch\DataPatchInterface;
1110
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
1211
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
@@ -16,8 +15,7 @@ use Magento\Framework\Setup\ModuleDataSetupInterface;
1615
* Patch is mechanism, that allows to do atomic upgrade data changes
1716
*/
1817
class %class% implements
19-
%patchInterface%,
20-
PatchVersionInterface
18+
%patchInterface%
2119
{
2220
/**
2321
* @var ModuleDataSetupInterface $moduleDataSetup
@@ -58,13 +56,4 @@ class %class% implements
5856

5957
];
6058
}
61-
62-
/**
63-
* {@inheritdoc}
64-
*/
65-
public static function getVersion()
66-
{
67-
return '';
68-
}
69-
7059
}
Lines changed: 30 additions & 0 deletions
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:setup:Model/Declaration/Schema/etc/schema.xsd">
10+
<table name="reference_table" resource="default">
11+
<column xsi:type="tinyint" name="tinyint_ref" padding="7" nullable="false" identity="true" unsigned="false"/>
12+
<column xsi:type="int" name="some_integer" default="0" nullable="false" unsigned="false"/>
13+
<column xsi:type="varchar" name="for_patch_testing" comment="For patch testing" />
14+
<constraint xsi:type="primary" name="tinyint_primary">
15+
<column name="tinyint_ref"/>
16+
</constraint>
17+
</table>
18+
<table name="test_table" resource="default">
19+
<!--Columns-->
20+
<column xsi:type="smallint" identity="true" name="smallint" padding="3" nullable="true"/>
21+
<column xsi:type="tinyint" name="tinyint" padding="7" nullable="true" unsigned="false"/>
22+
<column xsi:type="varchar" name="varchar" length="254" nullable="true"/>
23+
<column xsi:type="varbinary" name="varbinary" default="10101" />
24+
<constraint xsi:type="foreign" name="some_foreign_key" column="tinyint" table="test_table"
25+
referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="CASCADE"/>
26+
<constraint xsi:type="primary" name="PRIMARY">
27+
<column name="smallint" />
28+
</constraint>
29+
</table>
30+
</schema>
Lines changed: 10 additions & 0 deletions
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_TestSetupDeclarationModule5" setup_version="1.0.4" />
10+
</config>
Lines changed: 12 additions & 0 deletions
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+
7+
use Magento\Framework\Component\ComponentRegistrar;
8+
9+
$registrar = new ComponentRegistrar();
10+
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule5') === null) {
11+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule5', __DIR__);
12+
}
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_TestSetupDeclarationModule5" />
10+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\TestSetupDeclarationModule5\Setup;
7+
8+
use Magento\Framework\Setup\ModuleContextInterface;
9+
use Magento\Framework\Setup\ModuleDataSetupInterface;
10+
use Magento\Framework\Setup\UpgradeDataInterface;
11+
12+
/**
13+
* Class InstallData
14+
* @package Magento\TestSetupDeclarationModule3\Setup
15+
*/
16+
class UpgradeData implements UpgradeDataInterface
17+
{
18+
/**
19+
* {@inheritdoc}
20+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
21+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
22+
* @SuppressWarnings(PHPMD.NPathComplexity)
23+
*/
24+
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
25+
{
26+
$adapter = $setup->getConnection();
27+
$setup->startSetup();
28+
29+
if (version_compare($context->getVersion(), '1.0.2') < 0) {
30+
$adapter->insertArray('reference_table', ['some_integer'], [6, 12, 7]);
31+
}
32+
33+
if (version_compare($context->getVersion(), '1.0.3') < 0) {
34+
$adapter->delete('reference_table', 'some_integer = 7');
35+
}
36+
37+
$setup->endSetup();
38+
}
39+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\TestSetupDeclarationModule5\Setup\Patch\Data;
7+
8+
use Magento\Framework\App\ResourceConnection;
9+
use Magento\Setup\Model\Patch\DataPatchInterface;
10+
use Magento\Setup\Model\Patch\PatchRevertableInterface;
11+
use Magento\Setup\Model\Patch\PatchVersionInterface;
12+
13+
/**
14+
* Class SomePatch
15+
* @package Magento\TestSetupDeclarationModule3\Setup
16+
*/
17+
class SomePatch implements
18+
DataPatchInterface,
19+
PatchRevertableInterface,
20+
PatchVersionInterface
21+
{
22+
/**
23+
* @var ResourceConnection
24+
*/
25+
private $resourceConnection;
26+
27+
/**
28+
* IncrementalSomeIntegerPatch constructor.
29+
* @param ResourceConnection $resourceConnection
30+
*/
31+
public function __construct(ResourceConnection $resourceConnection)
32+
{
33+
$this->resourceConnection = $resourceConnection;
34+
}
35+
36+
/**
37+
* @return string
38+
*/
39+
public static function getVersion()
40+
{
41+
return '1.0.5';
42+
}
43+
44+
/**
45+
* @return array
46+
*/
47+
public function getAliases()
48+
{
49+
return [];
50+
}
51+
52+
/**
53+
* @inheritdoc
54+
*/
55+
public function apply()
56+
{
57+
$adapter = $this->resourceConnection->getConnection();
58+
$adapter->insert('test_table', ['varchar' => "_ref", 'varbinary' => 0101010]);
59+
}
60+
61+
public function revert()
62+
{
63+
}
64+
65+
/**
66+
* @return array
67+
*/
68+
public static function getDependencies()
69+
{
70+
return [];
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\TestSetupDeclarationModule5\Setup\Patch\Data;
7+
8+
use Magento\Framework\App\ResourceConnection;
9+
use Magento\Setup\Model\Patch\DataPatchInterface;
10+
use Magento\Setup\Model\Patch\PatchRevertableInterface;
11+
use Magento\Setup\Model\Patch\PatchVersionInterface;
12+
13+
/**
14+
* Class SomePatch
15+
* @package Magento\TestSetupDeclarationModule3\Setup
16+
*/
17+
class SomeSkippedPatch implements
18+
DataPatchInterface,
19+
PatchRevertableInterface,
20+
PatchVersionInterface
21+
{
22+
/**
23+
* @var ResourceConnection
24+
*/
25+
private $resourceConnection;
26+
27+
/**
28+
* IncrementalSomeIntegerPatch constructor.
29+
* @param ResourceConnection $resourceConnection
30+
*/
31+
public function __construct(ResourceConnection $resourceConnection)
32+
{
33+
$this->resourceConnection = $resourceConnection;
34+
}
35+
36+
/**
37+
* @return string
38+
*/
39+
public static function getVersion()
40+
{
41+
return '1.0.2';
42+
}
43+
44+
/**
45+
* @return array
46+
*/
47+
public function getAliases()
48+
{
49+
return [];
50+
}
51+
52+
/**
53+
* @inheritdoc
54+
*/
55+
public function apply()
56+
{
57+
throw new \Exception('This patch should be skipped!');
58+
}
59+
60+
public function revert()
61+
{
62+
}
63+
64+
/**
65+
* @return array
66+
*/
67+
public static function getDependencies()
68+
{
69+
return [];
70+
}
71+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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:setup:Model/Declaration/Schema/etc/schema.xsd">
10+
<table name="reference_table" resource="sales">
11+
<column xsi:type="tinyint" name="tinyint_ref" padding="7" nullable="false" identity="true" unsigned="false"/>
12+
<column xsi:type="tinyint" name="tinyint_without_padding" default="0" nullable="false" unsigned="false"/>
13+
<column xsi:type="bigint" name="bigint_without_padding" default="0" nullable="false" unsigned="false"/>
14+
<column xsi:type="smallint" name="smallint_without_padding" default="0" nullable="false" unsigned="false"/>
15+
<column xsi:type="int" name="integer_without_padding" default="0" nullable="false" unsigned="false"/>
16+
<column xsi:type="smallint" name="smallint_with_big_padding" padding="254" default="0" nullable="false"
17+
unsigned="false"/>
18+
<column xsi:type="smallint" name="smallint_without_default" padding="2" nullable="true" unsigned="false"/>
19+
<column xsi:type="int" name="int_without_unsigned" padding="2" nullable="true"/>
20+
<column xsi:type="int" name="int_unsigned" padding="2" nullable="true" unsigned="true"/>
21+
<column xsi:type="bigint" name="bigint_default_nullable" padding="2" nullable="true" default="1"
22+
unsigned="true"/>
23+
<column xsi:type="bigint" name="bigint_not_default_not_nullable" padding="2" nullable="false" unsigned="true"/>
24+
<constraint xsi:type="primary" name="tinyint_primary">
25+
<column name="tinyint_ref"/>
26+
</constraint>
27+
</table>
28+
<table name="auto_increment_test" resource="default">
29+
<column xsi:type="int" name="int_auto_increment_with_nullable" identity="true" padding="12" unsigned="true"
30+
nullable="true"/>
31+
<column xsi:type="smallint" name="int_disabled_auto_increment" default="0" identity="false" padding="12"
32+
unsigned="true" nullable="true"/>
33+
<constraint xsi:type="unique" name="unique_null_key">
34+
<column name="int_auto_increment_with_nullable"/>
35+
</constraint>
36+
</table>
37+
<table name="test_table" resource="default">
38+
<!--Columns-->
39+
<column xsi:type="smallint" identity="true" name="smallint" padding="3" nullable="true"/>
40+
<column xsi:type="tinyint" name="tinyint" padding="7" nullable="true" unsigned="false"/>
41+
<column xsi:type="bigint" name="bigint" default="0" padding="13" nullable="true" unsigned="false"/>
42+
<column xsi:type="float" name="float" default="0" scale="4" precision="12"/>
43+
<column xsi:type="decimal" name="double" default="11111111.111111" precision="14" scale="6"/>
44+
<column xsi:type="decimal" name="decimal" default="0" scale="4" precision="15"/>
45+
<column xsi:type="date" name="date"/>
46+
<column xsi:type="timestamp" name="timestamp" default="CURRENT_TIMESTAMP" on_update="true"/>
47+
<column xsi:type="datetime" name="datetime" default="0"/>
48+
<column xsi:type="longtext" name="longtext"/>
49+
<column xsi:type="mediumtext" name="mediumtext"/>
50+
<column xsi:type="varchar" name="varchar" length="254" nullable="true"/>
51+
<column xsi:type="mediumblob" name="mediumblob"/>
52+
<column xsi:type="blob" name="blob"/>
53+
<column xsi:type="boolean" name="boolean"/>
54+
<column xsi:type="varbinary" name="varbinary_rename" default="10101" disabled="true"/>
55+
<!--Constraints-->
56+
<constraint xsi:type="unique" name="some_unique_key">
57+
<column name="smallint"/>
58+
<column name="bigint"/>
59+
</constraint>
60+
<constraint xsi:type="foreign" name="some_foreign_key" column="tinyint" table="test_table"
61+
referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="NO ACTION"/>
62+
<!--Indexes-->
63+
<index name="speedup_index" indexType="btree">
64+
<column name="tinyint"/>
65+
<column name="bigint"/>
66+
</index>
67+
</table>
68+
</schema>

0 commit comments

Comments
 (0)