init
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\TestSetupDeclarationModule7\Setup;
|
||||
|
||||
use Magento\Framework\Setup\InstallSchemaInterface;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\SchemaSetupInterface;
|
||||
|
||||
/**
|
||||
* InstallSchema mock class
|
||||
*/
|
||||
class InstallSchema implements InstallSchemaInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
|
||||
{
|
||||
$installer = $setup;
|
||||
$installer->startSetup();
|
||||
$installer
|
||||
->getConnection()
|
||||
->modifyColumn('test_table', 'float', ['type' => 'float', 'default' => 25]);
|
||||
$installer->endSetup();
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestSetupDeclarationModule7\Setup;
|
||||
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
use Magento\Framework\Setup\UpgradeDataInterface;
|
||||
|
||||
/**
|
||||
* Class UpgradeData
|
||||
* @package Magento\TestSetupDeclarationModule7\Setup
|
||||
*/
|
||||
class UpgradeData implements UpgradeDataInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
|
||||
{
|
||||
$adapter = $setup->getConnection();
|
||||
$setup->startSetup();
|
||||
|
||||
if (version_compare($context->getVersion(), '2.0.0') < 0) {
|
||||
$adapter->insertArray('reference_table', ['bigint_without_padding'], [6, 12, 7]);
|
||||
}
|
||||
|
||||
$setup->endSetup();
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\TestSetupDeclarationModule7\Setup;
|
||||
|
||||
use Magento\Framework\Setup\InstallSchemaInterface;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\SchemaSetupInterface;
|
||||
use Magento\Framework\Setup\UpgradeSchemaInterface;
|
||||
|
||||
/**
|
||||
* UpgradeSchema mock class
|
||||
*/
|
||||
class UpgradeSchema implements UpgradeSchemaInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
|
||||
{
|
||||
$installer = $setup;
|
||||
$installer->startSetup();
|
||||
|
||||
if (version_compare($context->getVersion(), '2.0.1') < 0) {
|
||||
$installer
|
||||
->getConnection()
|
||||
->modifyColumn('test_table', 'float', ['type' => 'float', 'default' => 29]);
|
||||
}
|
||||
|
||||
$installer->endSetup();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?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_TestSetupDeclarationModule7" setup_version="2.0.1">
|
||||
<sequence>
|
||||
<module name="Magento_TestSetupDeclarationModule6" />
|
||||
</sequence>
|
||||
</module>
|
||||
</config>
|
||||
+12
@@ -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_TestSetupDeclarationModule7') === null) {
|
||||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule7', __DIR__);
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestSetupDeclarationModule7\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 SomePatch
|
||||
* @package Magento\TestSetupDeclarationModule3\Setup
|
||||
*/
|
||||
class SomePatch implements
|
||||
DataPatchInterface,
|
||||
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 '2.0.4';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAliases()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$adapter = $this->resourceConnection->getConnection();
|
||||
$adapter->insert('test_table', ['varchar' => "_ref"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getDependencies()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestSetupDeclarationModule7\Setup\Patch\Data;
|
||||
|
||||
use Magento\Framework\App\ResourceConnection;
|
||||
use Magento\Framework\Setup\Patch\DataPatchInterface;
|
||||
use Magento\Framework\Setup\Patch\PatchVersionInterface;
|
||||
|
||||
/**
|
||||
* Class SomePatch
|
||||
* @package Magento\TestSetupDeclarationModule3\Setup
|
||||
*/
|
||||
class SomeSkippedPatch implements
|
||||
DataPatchInterface,
|
||||
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 '2.0.2';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAliases()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
throw new \Exception('This patch should be skipped!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getDependencies()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?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="test_table">
|
||||
<column xsi:type="float" name="float" default="35" />
|
||||
</table>
|
||||
</schema>
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?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_TestSetupDeclarationModule7" setup_version="2.0.1">
|
||||
<sequence>
|
||||
<module name="Magento_TestSetupDeclarationModule6" />
|
||||
</sequence>
|
||||
</module>
|
||||
</config>
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestSetupDeclarationModule7\Setup;
|
||||
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
use Magento\Framework\Setup\UpgradeDataInterface;
|
||||
|
||||
/**
|
||||
* Class UpgradeData
|
||||
* @package Magento\TestSetupDeclarationModule3\Setup
|
||||
*/
|
||||
class UpgradeData implements UpgradeDataInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
|
||||
{
|
||||
$adapter = $setup->getConnection();
|
||||
$setup->startSetup();
|
||||
|
||||
if (version_compare($context->getVersion(), '2.0.0') < 0) {
|
||||
$adapter->insertArray('reference_table', ['bigint_without_padding'], [6, 12, 7]);
|
||||
}
|
||||
|
||||
if (version_compare($context->getVersion(), '2.0.2') < 0) {
|
||||
$adapter->delete('reference_table', 'bigint_without_padding = 7');
|
||||
}
|
||||
|
||||
$setup->endSetup();
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\TestSetupDeclarationModule7\Setup;
|
||||
|
||||
use Magento\Framework\Setup\InstallSchemaInterface;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\SchemaSetupInterface;
|
||||
use Magento\Framework\Setup\UpgradeSchemaInterface;
|
||||
|
||||
/**
|
||||
* UpgradeSchema mock class
|
||||
*/
|
||||
class UpgradeSchema implements UpgradeSchemaInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
|
||||
{
|
||||
$installer = $setup;
|
||||
$installer->startSetup();
|
||||
|
||||
if (version_compare($context->getVersion(), '2.0.1') < 0) {
|
||||
$installer
|
||||
->getConnection()
|
||||
->modifyColumn('test_table', 'float', ['type' => 'float', 'default' => 29]);
|
||||
}
|
||||
//Create table and check, that Magento can`t delete it
|
||||
if (version_compare($context->getVersion(), '2.0.2') < 0) {
|
||||
$table = $setup->getConnection()->newTable(
|
||||
$setup->getTable('custom_table')
|
||||
)->addColumn(
|
||||
'custom_id',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
|
||||
null,
|
||||
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
|
||||
'Custom Id'
|
||||
)->addColumn(
|
||||
'name',
|
||||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
|
||||
255,
|
||||
[],
|
||||
'Custom Name'
|
||||
)->setComment(
|
||||
'Custom Table'
|
||||
);
|
||||
$setup->getConnection()->createTable($table);
|
||||
}
|
||||
|
||||
$installer->endSetup();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?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_TestSetupDeclarationModule7" setup_version="2.0.2">
|
||||
<sequence>
|
||||
<module name="Magento_TestSetupDeclarationModule6" />
|
||||
</sequence>
|
||||
</module>
|
||||
</config>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"custom_table": {
|
||||
"column": {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user