This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,31 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestSetupDeclarationModule3\Setup;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
/**
* Class InstallData
* @package Magento\TestSetupDeclarationModule3\Setup
*/
class InstallData implements InstallDataInterface
{
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$adapter = $setup->getConnection();
$setup->startSetup();
$adapter->insertArray('reference_table', ['some_integer'], [7, 2, 3, 5]);
$setup->endSetup();
}
}
@@ -0,0 +1,29 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestSetupDeclarationModule3\Setup;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;
/**
* Class InstallData
* @package Magento\TestSetupDeclarationModule3\Setup
*/
class UpgradeData implements UpgradeDataInterface
{
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
$setup->endSetup();
}
}
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="reference_table" resource="default">
<column xsi:type="tinyint" name="tinyint_ref" padding="7" nullable="false" identity="true" unsigned="false"/>
<column xsi:type="int" name="some_integer" default="0" nullable="false" unsigned="false"/>
<column xsi:type="varchar" name="for_patch_testing" comment="For patch testing" />
<constraint xsi:type="primary" referenceId="tinyint_primary">
<column name="tinyint_ref"/>
</constraint>
</table>
<table name="test_table" resource="default">
<!--Columns-->
<column xsi:type="smallint" identity="true" name="smallint" padding="3" nullable="true"/>
<column xsi:type="tinyint" name="tinyint" padding="7" nullable="true" unsigned="false"/>
<column xsi:type="varchar" name="varchar" length="254" nullable="true"/>
<column xsi:type="varbinary" name="varbinary" default="10101" />
<constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF"
column="tinyint" table="test_table"
referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="CASCADE"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="smallint" />
</constraint>
</table>
</schema>
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_TestSetupDeclarationModule3" setup_version="0.0.1"/>
</config>
@@ -0,0 +1,12 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\Component\ComponentRegistrar;
$registrar = new ComponentRegistrar();
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule3') === null) {
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule3', __DIR__);
}
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_TestSetupDeclarationModule3" setup_version="0.0.3"/>
</config>
@@ -0,0 +1,72 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestSetupDeclarationModule3\Setup\Patch\Data;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
* @package Magento\TestSetupDeclarationModule3\Setup
*/
class BicPatch implements
DataPatchInterface,
PatchRevertableInterface,
PatchVersionInterface
{
/**
* @var ResourceConnection
*/
private $resourceConnection;
/**
* IncrementalSomeIntegerPatch constructor.
* @param ResourceConnection $resourceConnection
*/
public function __construct(ResourceConnection $resourceConnection)
{
$this->resourceConnection = $resourceConnection;
}
/**
* @return string
*/
public function getVersion()
{
return '0.0.3';
}
/**
* @return array
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public function apply()
{
throw new \Exception("This patch can`t be applied, as it was created to test BIC");
}
public function revert()
{
}
/**
* @return array
*/
public static function getDependencies()
{
return [
RefBicPatch::class
];
}
}
@@ -0,0 +1,72 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestSetupDeclarationModule3\Setup\Patch\Data;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
* @package Magento\TestSetupDeclarationModule3\Setup
*/
class RefBicPatch implements
DataPatchInterface,
PatchRevertableInterface,
PatchVersionInterface
{
/**
* @var ResourceConnection
*/
private $resourceConnection;
/**
* IncrementalSomeIntegerPatch constructor.
* @param ResourceConnection $resourceConnection
*/
public function __construct(ResourceConnection $resourceConnection)
{
$this->resourceConnection = $resourceConnection;
}
/**
* @return string
*/
public function getVersion()
{
return '0.0.3';
}
/**
* @return array
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public function apply()
{
throw new \Exception("This patch can`t be applied, as it was created to test BIC");
}
public function revert()
{
}
/**
* @return array
*/
public static function getDependencies()
{
return [
BicPatch::class
];
}
}
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_TestSetupDeclarationModule3" setup_version="0.0.3" />
</config>
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="reference_table" disabled="true"/>
</schema>
@@ -0,0 +1,39 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestSetupDeclarationModule3\Setup;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;
/**
* Class InstallData
* @package Magento\TestSetupDeclarationModule3\Setup
*/
class UpgradeData implements UpgradeDataInterface
{
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$adapter = $setup->getConnection();
$setup->startSetup();
if (version_compare($context->getVersion(), '0.0.2') < 0) {
$adapter->insertArray('reference_table', ['some_integer'], [6, 12]);
}
if (version_compare($context->getVersion(), '0.0.3') < 0) {
$adapter->delete('reference_table', 'some_integer = 7');
}
$setup->endSetup();
}
}
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_TestSetupDeclarationModule3" setup_version="0.0.3"/>
</config>
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_TestSetupDeclarationModule3" setup_version="0.0.2"/>
</config>
@@ -0,0 +1,91 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestSetupDeclarationModule3\Setup\Patch\Data;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
* Class InstallData
* @package Magento\TestSetupDeclarationModule3\Setup
*/
class IncrementalSomeIntegerPatch implements
DataPatchInterface,
PatchRevertableInterface,
PatchVersionInterface
{
/**
* @var ResourceConnection
*/
private $resourceConnection;
/**
* IncrementalSomeIntegerPatch constructor.
* @param ResourceConnection $resourceConnection
*/
public function __construct(ResourceConnection $resourceConnection)
{
$this->resourceConnection = $resourceConnection;
}
/**
* @return string
*/
public static function getVersion()
{
return '1.0.5';
}
/**
* @return array
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public function apply()
{
$adapter = $this->resourceConnection->getConnection();
$select = $adapter->select()->from('test_table', 'varchar')
->where('`smallint` = ?', 1);
$refSelect = $adapter->select()->from('reference_table', 'for_patch_testing')
->where('`tinyint_ref` = ?', 7);
$varchar = $adapter->fetchOne($select);
$varchar2 = $adapter->fetchOne($refSelect);
$adapter->insert('test_table', ['varchar' => $varchar . "_ref", 'varbinary' => 0101010]);
$adapter->insert('test_table', ['varchar' => $varchar2, 'varbinary' => 0]);
}
public function revert()
{
$adapter = $this->resourceConnection->getConnection();
$select = $adapter->select()->from('test_table', 'varchar')
->where('`smallint` = ?', 1);
$varchar = $adapter->fetchOne($select);
$refSelect = $adapter->select()->from('reference_table', 'for_patch_testing')
->where('`tinyint_ref` = ?', 7);
$varchar2 = $adapter->fetchOne($refSelect);
$adapter->delete('test_table', ['`varchar` = ?' => $varchar . "_ref"]);
$adapter->delete('test_table', ['`varchar` = ?' => $varchar2]);
}
/**
* @return array
*/
public static function getDependencies()
{
return [
ReferenceIncrementalSomeIntegerPatch::class,
NextChainPatch::class
];
}
}
@@ -0,0 +1,75 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestSetupDeclarationModule3\Setup\Patch\Data;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
* @package Magento\TestSetupDeclarationModule3\Setup
*/
class LlNextChainPatch implements
DataPatchInterface,
PatchRevertableInterface,
PatchVersionInterface
{
/**
* @var ResourceConnection
*/
private $resourceConnection;
/**
* IncrementalSomeIntegerPatch constructor.
* @param ResourceConnection $resourceConnection
*/
public function __construct(ResourceConnection $resourceConnection)
{
$this->resourceConnection = $resourceConnection;
}
/**
* @return string
*/
public static function getVersion()
{
return '0.0.5';
}
/**
* @return array
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public function apply()
{
$adapter = $this->resourceConnection->getConnection();
$adapter->insertArray('reference_table', ['for_patch_testing'], ['very_secret_string']);
}
public function revert()
{
$adapter = $this->resourceConnection->getConnection();
$adapter->delete('reference_table', ['for_patch_testing = ?' => 'very_secret_string']);
}
/**
* @return array
*/
public static function getDependencies()
{
return [
ZFirstPatch::class
];
}
}
@@ -0,0 +1,90 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestSetupDeclarationModule3\Setup\Patch\Data;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
* @package Magento\TestSetupDeclarationModule3\Setup
*/
class NextChainPatch implements
DataPatchInterface,
PatchRevertableInterface,
PatchVersionInterface
{
/**
* @var ResourceConnection
*/
private $resourceConnection;
/**
* IncrementalSomeIntegerPatch constructor.
* @param ResourceConnection $resourceConnection
*/
public function __construct(ResourceConnection $resourceConnection)
{
$this->resourceConnection = $resourceConnection;
}
/**
* @return string
*/
public static function getVersion()
{
return '0.0.6';
}
/**
* @return array
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public function apply()
{
$adapter = $this->resourceConnection->getConnection();
$refSelect = $adapter->select()->from('reference_table', 'for_patch_testing')
->where('`tinyint_ref` = ?', 7);
$varchar2 = $adapter->fetchOne($refSelect);
$adapter->update(
'reference_table',
['for_patch_testing' => 'changed__' . $varchar2],
['`tinyint_ref` = ?' => 7]
);
}
public function revert()
{
$adapter = $this->resourceConnection->getConnection();
$refSelect = $adapter->select()->from('reference_table', 'for_patch_testing')
->where('`tinyint_ref` = ?', 7);
$varchar2 = $adapter->fetchOne($refSelect);
$adapter->update(
'reference_table',
['for_patch_testing' => str_replace('changed__', '', $varchar2)],
['`tinyint_ref` = ?' => 7]
);
}
/**
* @return array
*/
public static function getDependencies()
{
return [
LlNextChainPatch::class,
ZFirstPatch::class
];
}
}
@@ -0,0 +1,76 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestSetupDeclarationModule3\Setup\Patch\Data;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
* Class ReferenceIncrementalSomeIntegerPatch
* @package Magento\TestSetupDeclarationModule3\Setup
*/
class ReferenceIncrementalSomeIntegerPatch implements
DataPatchInterface,
PatchRevertableInterface,
PatchVersionInterface
{
/**
* @var ResourceConnection
*/
private $resourceConnection;
/**
* IncrementalSomeIntegerPatch constructor.
* @param ResourceConnection $resourceConnection
*/
public function __construct(ResourceConnection $resourceConnection)
{
$this->resourceConnection = $resourceConnection;
}
/**
* @return string
*/
public static function getVersion()
{
return '0.0.4';
}
/**
* @return array
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public function apply()
{
$adapter = $this->resourceConnection->getConnection();
$adapter->insert('test_table', ['varchar' => 'Ololo123', 'varbinary' => 0101010]);
}
public function revert()
{
$adapter = $this->resourceConnection->getConnection();
$adapter->delete('test_table', ['`smallint` = ?' => 1]);
}
/**
* @return array
*/
public static function getDependencies()
{
return [
ZFirstPatch::class
];
}
}
@@ -0,0 +1,72 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestSetupDeclarationModule3\Setup\Patch\Data;
use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Exception;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
* Class InstallData
* @package Magento\TestSetupDeclarationModule3\Setup
*/
class ZFirstPatch implements
DataPatchInterface,
PatchVersionInterface,
PatchRevertableInterface
{
/**
* @var ResourceConnection
*/
private $resourceConnection;
/**
* IncrementalSomeIntegerPatch constructor.
* @param ResourceConnection $resourceConnection
*/
public function __construct(ResourceConnection $resourceConnection)
{
$this->resourceConnection = $resourceConnection;
}
/**
* @return string
*/
public static function getVersion()
{
return '0.0.3';
}
/**
* @return array
*/
public function getAliases()
{
return [];
}
public function revert()
{
}
/**
* @inheritdoc
*/
public function apply()
{
throw new Exception('This patch should be covered by old script!');
}
/**
* @return array
*/
public static function getDependencies()
{
return [];
}
}
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_TestSetupDeclarationModule3"/>
</config>