ltsecurityinc安防产品在线商城代码
This commit is contained in:
+11
@@ -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>
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestSetupDeclarationModule9\Setup;
|
||||
|
||||
use Magento\Framework\DB\Adapter\AdapterInterface;
|
||||
use Magento\Framework\DB\Ddl\Table;
|
||||
use Magento\Framework\Setup\InstallSchemaInterface;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\SchemaSetupInterface;
|
||||
|
||||
/**
|
||||
* Install schema script for the TestSetupDeclarationModule9 module.
|
||||
*/
|
||||
class InstallSchema implements InstallSchemaInterface
|
||||
{
|
||||
/**
|
||||
* The name of the main table of Module9.
|
||||
*/
|
||||
const MAIN_TABLE = 'module9_test_main_table';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \Zend_Db_Exception
|
||||
*/
|
||||
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
|
||||
{
|
||||
$setup->startSetup();
|
||||
|
||||
$this->createTables($setup);
|
||||
|
||||
$setup->endSetup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create tables.
|
||||
*
|
||||
* @param SchemaSetupInterface $installer
|
||||
* @throws \Zend_Db_Exception
|
||||
*/
|
||||
private function createTables(SchemaSetupInterface $installer)
|
||||
{
|
||||
$mainTableName = $installer->getTable(self::MAIN_TABLE);
|
||||
$this->dropTableIfExists($installer, $mainTableName);
|
||||
$mainTable = $installer->getConnection()->newTable($mainTableName);
|
||||
$mainTable->setComment('Main Test Table for Module9');
|
||||
$this->addColumnsToMainTable($mainTable);
|
||||
$this->addIndexesToMainTable($mainTable);
|
||||
$installer->getConnection()->createTable($mainTable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop existing tables.
|
||||
*
|
||||
* @param SchemaSetupInterface $installer
|
||||
* @param string $table
|
||||
*/
|
||||
private function dropTableIfExists($installer, $table)
|
||||
{
|
||||
$connection = $installer->getConnection();
|
||||
if ($connection->isTableExists($installer->getTable($table))) {
|
||||
$connection->dropTable(
|
||||
$installer->getTable($table)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add tables to main table.
|
||||
*
|
||||
* @param Table $table
|
||||
* @throws \Zend_Db_Exception
|
||||
*/
|
||||
private function addColumnsToMainTable($table)
|
||||
{
|
||||
$table
|
||||
->addColumn(
|
||||
'module9_email_contact_id',
|
||||
Table::TYPE_INTEGER,
|
||||
10,
|
||||
[
|
||||
'primary' => true,
|
||||
'identity' => true,
|
||||
'unsigned' => true,
|
||||
'nullable' => false
|
||||
],
|
||||
'Entity ID'
|
||||
)->addColumn(
|
||||
'module9_is_guest',
|
||||
Table::TYPE_SMALLINT,
|
||||
null,
|
||||
[
|
||||
'unsigned' => true,
|
||||
'nullable' => true
|
||||
],
|
||||
'Is Guest'
|
||||
)->addColumn(
|
||||
'module9_guest_id',
|
||||
Table::TYPE_INTEGER,
|
||||
null,
|
||||
[
|
||||
'unsigned' => true
|
||||
],
|
||||
'Guest ID'
|
||||
)
|
||||
->addColumn(
|
||||
'module9_created_at',
|
||||
Table::TYPE_DATE,
|
||||
null,
|
||||
[],
|
||||
'Created At'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add indexes to main table.
|
||||
*
|
||||
* @param Table $table
|
||||
* @throws \Zend_Db_Exception
|
||||
*/
|
||||
private function addIndexesToMainTable($table)
|
||||
{
|
||||
$table
|
||||
->addIndex(
|
||||
'MODULE9_INSTALL_UNIQUE_INDEX_1',
|
||||
['module9_email_contact_id', 'module9_guest_id'],
|
||||
['type' => AdapterInterface::INDEX_TYPE_UNIQUE]
|
||||
);
|
||||
}
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestSetupDeclarationModule9\Setup;
|
||||
|
||||
use Magento\Framework\DB\Ddl\Table;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\SchemaSetupInterface;
|
||||
use Magento\Framework\Setup\UpgradeSchemaInterface;
|
||||
use Magento\TestSetupDeclarationModule8\Setup\InstallSchema as Module8InstallSchema;
|
||||
use Magento\TestSetupDeclarationModule8\Setup\UpgradeSchema as Module8UpgradeSchema;
|
||||
|
||||
/**
|
||||
* Upgrade schema script for the TestSetupDeclarationModule9 module.
|
||||
*/
|
||||
class UpgradeSchema implements UpgradeSchemaInterface
|
||||
{
|
||||
/**
|
||||
* The name of the main table of Module9.
|
||||
*/
|
||||
const REPLICA_TABLE = 'module9_test_update_replica_table';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \Zend_Db_Exception
|
||||
*/
|
||||
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
|
||||
{
|
||||
$setup->startSetup();
|
||||
|
||||
if (version_compare($context->getVersion(), '2.0.0', '<')) {
|
||||
$this->addColumns($setup);
|
||||
$this->addIndexes($setup);
|
||||
$this->addConstraints($setup);
|
||||
$this->removeColumns($setup);
|
||||
$this->removeIndexes($setup);
|
||||
$this->removeConstraints($setup);
|
||||
$this->removeTables($setup);
|
||||
$replicaTable = $setup->getConnection()
|
||||
->createTableByDdl(Module8InstallSchema::SECOND_TABLE, self::REPLICA_TABLE);
|
||||
$setup->getConnection()->createTable($replicaTable);
|
||||
}
|
||||
|
||||
$setup->endSetup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create columns for tables.
|
||||
*
|
||||
* @param SchemaSetupInterface $setup
|
||||
*/
|
||||
private function addColumns(SchemaSetupInterface $setup): void
|
||||
{
|
||||
$setup->getConnection()->addColumn(
|
||||
InstallSchema::MAIN_TABLE,
|
||||
'module9_update_column',
|
||||
[
|
||||
'type' => Table::TYPE_INTEGER,
|
||||
'nullable' => false,
|
||||
'comment' => 'Module_9 Update Column',
|
||||
]
|
||||
);
|
||||
|
||||
$setup->getConnection()->addColumn(
|
||||
Module8InstallSchema::MAIN_TABLE,
|
||||
'module9_update_column',
|
||||
[
|
||||
'type' => Table::TYPE_INTEGER,
|
||||
'nullable' => false,
|
||||
'comment' => 'Module_9 Update Column',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add indexes.
|
||||
*
|
||||
* @param SchemaSetupInterface $setup
|
||||
*/
|
||||
private function addIndexes(SchemaSetupInterface $setup): void
|
||||
{
|
||||
$setup->getConnection()
|
||||
->addIndex(
|
||||
Module8UpgradeSchema::UPDATE_TABLE,
|
||||
'MODULE9_UPDATE_MODULE8_GUEST_BROWSER_ID',
|
||||
[
|
||||
'module8_guest_browser_id'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add constraints.
|
||||
*
|
||||
* @param SchemaSetupInterface $setup
|
||||
*/
|
||||
private function addConstraints(SchemaSetupInterface $setup): void
|
||||
{
|
||||
$setup->getConnection()
|
||||
->addForeignKey(
|
||||
'MODULE9_UPDATE_FK_MODULE9_IS_GUEST',
|
||||
InstallSchema::MAIN_TABLE,
|
||||
'module9_is_guest',
|
||||
Module8InstallSchema::MAIN_TABLE,
|
||||
'module8_is_guest',
|
||||
Table::ACTION_CASCADE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove columns.
|
||||
*
|
||||
* @param SchemaSetupInterface $setup
|
||||
*/
|
||||
private function removeColumns(SchemaSetupInterface $setup): void
|
||||
{
|
||||
$setup->getConnection()
|
||||
->dropColumn(
|
||||
Module8UpgradeSchema::UPDATE_TABLE,
|
||||
'module8_column_for_remove'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove indexes.
|
||||
*
|
||||
* @param SchemaSetupInterface $setup
|
||||
*/
|
||||
private function removeIndexes(SchemaSetupInterface $setup): void
|
||||
{
|
||||
$connection = $setup->getConnection();
|
||||
$connection
|
||||
->dropIndex(
|
||||
Module8InstallSchema::SECOND_TABLE,
|
||||
'MODULE8_INSTALL_SECOND_TABLE_INDEX_3_TEMP'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove constraints.
|
||||
*
|
||||
* @param SchemaSetupInterface $setup
|
||||
*/
|
||||
private function removeConstraints(SchemaSetupInterface $setup): void
|
||||
{
|
||||
$setup->getConnection()
|
||||
->dropForeignKey(
|
||||
Module8InstallSchema::SECOND_TABLE,
|
||||
'MODULE8_INSTALL_FK_ADDRESS_TEST_MAIN_TABLE_CONTACT_ID'
|
||||
)->dropIndex(
|
||||
Module8UpgradeSchema::UPDATE_TABLE,
|
||||
'MODULE8_UPDATE_UNIQUE_INDEX_TEMP'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove tables.
|
||||
*
|
||||
* @param SchemaSetupInterface $setup
|
||||
*/
|
||||
private function removeTables(SchemaSetupInterface $setup): void
|
||||
{
|
||||
$setup->getConnection()
|
||||
->dropTable(
|
||||
Module8UpgradeSchema::TEMP_TABLE
|
||||
);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?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_TestSetupDeclarationModule9" setup_version="2.0.0">
|
||||
<sequence>
|
||||
<module name="Magento_TestSetupDeclarationModule8"/>
|
||||
</sequence>
|
||||
</module>
|
||||
</config>
|
||||
Reference in New Issue
Block a user