Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     /** @var CustomerSetup $customerSetup */
     $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
     if (version_compare($context->getVersion(), '2.0.1', '<')) {
         $entityAttributes = ['customer' => ['website_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'created_in' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'email' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'group_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'dob' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'taxvat' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'confirmation' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'created_at' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'gender' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false]], 'customer_address' => ['company' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'street' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'city' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'country_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'region' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'region_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'postcode' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'telephone' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'fax' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true]]];
         $this->upgradeAttributes($entityAttributes, $customerSetup);
     }
     if (version_compare($context->getVersion(), '2.0.2') < 0) {
         $entityTypeId = $customerSetup->getEntityTypeId(Customer::ENTITY);
         $attributeId = $customerSetup->getAttributeId($entityTypeId, 'gender');
         $option = ['attribute_id' => $attributeId, 'values' => [3 => 'Not Specified']];
         $customerSetup->addAttributeOption($option);
     }
     if (version_compare($context->getVersion(), '2.0.3', '<')) {
         $entityAttributes = ['customer_address' => ['region_id' => ['is_used_in_grid' => false, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => false], 'firstname' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'lastname' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true]]];
         $this->upgradeAttributes($entityAttributes, $customerSetup);
     }
     if (version_compare($context->getVersion(), '2.0.4', '<')) {
         $customerSetup->addAttribute(Customer::ENTITY, 'updated_at', ['type' => 'static', 'label' => 'Updated At', 'input' => 'date', 'required' => false, 'sort_order' => 87, 'visible' => false, 'system' => false]);
     }
     if (version_compare($context->getVersion(), '2.0.5', '<')) {
         $this->upgradeHash($setup);
         $entityAttributes = ['customer_address' => ['fax' => ['is_visible' => false, 'is_system' => false]]];
         $this->upgradeAttributes($entityAttributes, $customerSetup);
     }
     $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
     $indexer->reindexAll();
     $this->eavConfig->clear();
     $setup->endSetup();
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '2.0.0.1') < 0) {
         $installer = $setup;
         $connection = $installer->getConnection();
         $tableNames = ['customer_address_entity_varchar', 'customer_address_entity_datetime', 'customer_address_entity_decimal', 'customer_address_entity_int', 'customer_address_entity_text', 'customer_entity_varchar', 'customer_entity_datetime', 'customer_entity_decimal', 'customer_entity_int', 'customer_entity_text'];
         foreach ($tableNames as $table) {
             $connection->dropForeignKey($installer->getTable($table), $installer->getFkName($table, 'entity_type_id', 'eav_entity_type', 'entity_type_id'));
             $connection->dropIndex($installer->getTable($table), $installer->getIdxName($installer->getTable($table), ['entity_type_id'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX));
             $connection->dropColumn($installer->getTable($table), 'entity_type_id');
         }
         $connection->dropColumn($installer->getTable('customer_address_entity'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('customer_address_entity'), 'attribute_set_id');
         $connection->dropIndex($installer->getTable('customer_entity'), $installer->getIdxName('customer_entity', ['entity_type_id']));
         $connection->dropColumn($installer->getTable('customer_entity'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('customer_entity'), 'attribute_set_id');
     }
     if (version_compare($context->getVersion(), '2.0.0.2') < 0) {
         /**
          * Update 'customer_visitor' table.
          */
         $setup->getConnection()->addColumn($setup->getTable('customer_visitor'), 'customer_id', ['type' => Table::TYPE_INTEGER, 'after' => 'visitor_id', 'comment' => 'Customer ID']);
         $setup->getConnection()->addIndex($setup->getTable('customer_visitor'), $setup->getIdxName($setup->getTable('customer_visitor'), ['customer_id']), 'customer_id');
         /**
          * Create 'customer_log' table.
          */
         $table = $setup->getConnection()->newTable($setup->getTable('customer_log'))->addColumn('log_id', Table::TYPE_INTEGER, null, ['nullable' => false, 'identity' => true, 'primary' => true], 'Log ID')->addColumn('customer_id', Table::TYPE_INTEGER, null, ['nullable' => false], 'Customer ID')->addColumn('last_login_at', Table::TYPE_TIMESTAMP, null, ['nullable' => true, 'default' => null], 'Last Login Time')->addColumn('last_logout_at', Table::TYPE_TIMESTAMP, null, ['nullable' => true, 'default' => null], 'Last Logout Time')->addIndex($setup->getIdxName($setup->getTable('customer_log'), ['customer_id'], AdapterInterface::INDEX_TYPE_UNIQUE), ['customer_id'], ['type' => AdapterInterface::INDEX_TYPE_UNIQUE])->setComment('Customer Log Table');
         $setup->getConnection()->createTable($table);
     }
     $setup->endSetup();
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if ($context->getVersion() && version_compare($context->getVersion(), '2.0.1') < 0) {
         $select = $setup->getConnection()->select()->from($setup->getTable('catalog_product_entity_group_price'), ['entity_id', 'all_groups', 'customer_group_id', new \Zend_Db_Expr('1'), 'value', 'website_id']);
         $select = $setup->getConnection()->insertFromSelect($select, $setup->getTable('catalog_product_entity_tier_price'), ['entity_id', 'all_groups', 'customer_group_id', 'qty', 'value', 'website_id']);
         $setup->getConnection()->query($select);
         $categorySetupManager = $this->categorySetupFactory->create();
         $categorySetupManager->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'group_price');
     }
     if (version_compare($context->getVersion(), '2.0.2') < 0) {
         // set new resource model paths
         /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
         $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Category');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Category\\Attribute\\Collection');
         $categorySetup->updateAttribute(\Magento\Catalog\Model\Category::ENTITY, 'custom_design_from', 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Product');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection');
     }
     if (version_compare($context->getVersion(), '2.0.3') < 0) {
         /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
         $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
         $categorySetup->updateAttribute(3, 51, 'default_value', 1);
     }
     if (version_compare($context->getVersion(), '2.0.4') < 0) {
         /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
         $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
         $categorySetup->updateAttribute('catalog_product', 'media_gallery', 'backend_type', 'static');
         $categorySetup->updateAttribute('catalog_product', 'media_gallery', 'backend_model');
     }
     $setup->endSetup();
 }
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $installer = $setup;
     $connection = $installer->getConnection();
     if (version_compare($context->getVersion(), '2.0.1') < 0) {
         $connection->dropIndex($setup->getTable('search_query'), $installer->getIdxName('search_query', ['query_text', 'store_id']));
         $connection->addIndex($setup->getTable('search_query'), $installer->getIdxName('search_query', ['query_text', 'store_id'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE), ['query_text', 'store_id'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE);
     }
     if (version_compare($context->getVersion(), '2.0.2') < 0) {
         /**
          * Create table 'search_synonyms'
          */
         $table = $connection->newTable($installer->getTable('search_synonyms'))->addColumn('group_id', \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'Synonyms Group Id')->addColumn('synonyms', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 65535, ['nullable' => false], 'list of synonyms making up this group')->addColumn('store_id', \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, null, ['unsigned' => true, 'nullable' => false, 'default' => '0'], 'Store Id - identifies the store view these synonyms belong to')->addIndex($setup->getIdxName($installer->getTable('search_synonyms'), ['synonyms'], AdapterInterface::INDEX_TYPE_FULLTEXT), ['synonyms'], ['type' => AdapterInterface::INDEX_TYPE_FULLTEXT])->addIndex($installer->getIdxName('search_synonyms', 'store_id'), ['store_id'], ['type' => AdapterInterface::INDEX_TYPE_INDEX])->addForeignKey($installer->getFkName('search_synonyms', 'store_id', 'store', 'store_id'), 'store_id', $installer->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE)->setComment('table storing various synonyms groups per store view');
         $connection->createTable($table);
     }
     if (version_compare($context->getVersion(), '2.0.3') < 0) {
         // Drop and recreate 'search_synonyms' table
         $connection->dropTable($installer->getTable('search_synonyms'));
         $table = $connection->newTable($installer->getTable('search_synonyms'))->addColumn('group_id', \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'Synonyms Group Id')->addColumn('synonyms', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 65535, ['nullable' => false], 'list of synonyms making up this group')->addColumn('store_id', \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, null, ['unsigned' => true, 'nullable' => false, 'default' => '0'], 'Store Id - identifies the store view these synonyms belong to')->addColumn('website_id', \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, null, ['unsigned' => true, 'nullable' => false, 'default' => '0'], 'Website Id - identifies the website id these synonyms belong to')->addIndex($setup->getIdxName($installer->getTable('search_synonyms'), ['synonyms'], AdapterInterface::INDEX_TYPE_FULLTEXT), ['synonyms'], ['type' => AdapterInterface::INDEX_TYPE_FULLTEXT])->addIndex($installer->getIdxName('search_synonyms', 'store_id'), ['store_id'], ['type' => AdapterInterface::INDEX_TYPE_INDEX])->addIndex($installer->getIdxName('search_synonyms', 'website_id'), ['website_id'], ['type' => AdapterInterface::INDEX_TYPE_INDEX])->addForeignKey($installer->getFkName('search_synonyms', 'store_id', 'store', 'store_id'), 'store_id', $installer->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE)->addForeignKey($installer->getFkName('search_synonyms', 'website_id', 'store_website', 'website_id'), 'website_id', $installer->getTable('store_website'), 'website_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE)->setComment('table storing various synonyms groups');
         $connection->createTable($table);
     }
     if (version_compare($context->getVersion(), '2.0.4') < 0) {
         $connection->dropIndex($setup->getTable('search_query'), $installer->getIdxName('search_query', 'synonym_for'));
         $connection->dropColumn($setup->getTable('search_query'), 'synonym_for');
     }
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '2.0.1') < 0) {
         /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
         $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
         $entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
         $attributeSetId = $categorySetup->getDefaultAttributeSetId($entityTypeId);
         $attributeGroup = $categorySetup->getAttributeGroup($entityTypeId, $attributeSetId, 'Images', 'attribute_group_name');
         if (isset($attributeGroup['attribute_group_name']) && $attributeGroup['attribute_group_name'] == 'Images') {
             // update General Group
             $categorySetup->updateAttributeGroup($entityTypeId, $attributeSetId, $attributeGroup['attribute_group_id'], 'attribute_group_name', 'Images and Videos');
         }
     }
     if ($context->getVersion() && version_compare($context->getVersion(), '2.0.1') < 0) {
         $select = $setup->getConnection()->select()->from($setup->getTable('catalog_product_entity_group_price'), ['entity_id', 'all_groups', 'customer_group_id', new \Zend_Db_Expr('1'), 'value', 'website_id']);
         $select = $setup->getConnection()->insertFromSelect($select, $setup->getTable('catalog_product_entity_tier_price'), ['entity_id', 'all_groups', 'customer_group_id', 'qty', 'value', 'website_id']);
         $setup->getConnection()->query($select);
         $categorySetupManager = $this->categorySetupFactory->create();
         $categorySetupManager->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'group_price');
     }
     if (version_compare($context->getVersion(), '2.0.2') < 0) {
         // set new resource model paths
         /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
         $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Category');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Category\\Attribute\\Collection');
         $categorySetup->updateAttribute(\Magento\Catalog\Model\Category::ENTITY, 'custom_design_from', 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Product');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection');
     }
     $setup->endSetup();
 }
 /**
  * {@inheritdoc}
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     $connection = $setup->getConnection();
     if (version_compare($context->getVersion(), '1.1.0', '<')) {
         //remove quote table
         $connection->dropTable($setup->getTable('email_quote'));
     }
     if (version_compare($context->getVersion(), '2.0.6', '<')) {
         //modify email_campaign table
         $campaignTable = $setup->getTable('email_campaign');
         //add columns
         $connection->addColumn($campaignTable, 'send_id', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => false, 'default' => '', 'comment' => 'Campaign Send Id']);
         $connection->addColumn($campaignTable, 'send_status', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'nullable' => false, 'default' => 0, 'comment' => 'Send Status']);
         if ($connection->tableColumnExists($campaignTable, 'is_sent')) {
             //update table with historical send values
             $select = $connection->select();
             //join
             $select->joinLeft(['oc' => $campaignTable], "oc.id = nc.id", ['send_status' => new \Zend_Db_Expr(\Dotdigitalgroup\Email\Model\Campaign::SENT)])->where('oc.is_sent =?', 1);
             //update query from select
             $updateSql = $select->crossUpdateFromSelect(['nc' => $campaignTable]);
             //run query
             $connection->query($updateSql);
             //remove column
             $connection->dropColumn($campaignTable, 'is_sent');
         }
         //add index
         $connection->addIndex($campaignTable, $setup->getIdxName($campaignTable, ['send_status']), ['send_status']);
     }
     if (version_compare($context->getVersion(), '2.1.0', '<')) {
         $couponTable = $setup->getTable('salesrule_coupon');
         $connection->addColumn($couponTable, 'generated_by_dotmailer', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'nullable' => true, 'default' => null, 'comment' => '1 = Generated by dotmailer']);
     }
     $setup->endSetup();
 }
Ejemplo n.º 7
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '1.0.0.1', '<')) {
         $this->updateSchemaVersion1001($setup);
     }
     if (version_compare($context->getVersion(), '1.0.0.2', '<')) {
         $this->updateSchemaVersion1002($setup);
     }
     $setup->endSetup();
 }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '2.0.1', '<')) {
         $setup->getConnection()->addIndex($setup->getTable('quote_id_mask'), $setup->getIdxName('quote_id_mask', ['masked_id']), ['masked_id']);
     }
     if (version_compare($context->getVersion(), '2.0.2', '<')) {
         $setup->getConnection()->changeColumn($setup->getTable('quote_address'), 'street', 'street', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'comment' => 'Street']);
     }
     $setup->endSetup();
 }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '2.0.1', '<')) {
         $this->addSupportVideoMediaAttributes($setup);
         $this->removeGroupPrice($setup);
     }
     if (version_compare($context->getVersion(), '2.0.6', '<')) {
         $this->addUniqueKeyToCategoryProductTable($setup);
     }
     $setup->endSetup();
 }
Ejemplo n.º 10
0
 /**
  * Upgrade the module data.
  *
  * @param ModuleDataSetupInterface $setup   The setup interface
  * @param ModuleContextInterface   $context The module Context
  *
  * @return void
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     $this->eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
     if (version_compare($context->getVersion(), '1.2.0', '<')) {
         $this->updateCategorySearchableAttributes();
     }
     if (version_compare($context->getVersion(), '1.2.1', '<')) {
         $productImageAttributeId = $this->eavSetup->getAttributeId(\Magento\Catalog\Model\Product::ENTITY, 'image');
         $setup->getConnection()->update($setup->getTable('catalog_eav_attribute'), ['is_searchable' => 1], $setup->getConnection()->quoteInto('attribute_id = ?', $productImageAttributeId));
     }
     $setup->endSetup();
 }
Ejemplo n.º 11
0
 /**
  * Installs DB schema for a module
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  *
  * @param SchemaSetupInterface   $setup   Setup
  * @param ModuleContextInterface $context Context
  *
  * @return void
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '0.0.2', '<')) {
         $this->createThesaurusTable($setup);
         $this->createThesaurusStoreTable($setup);
         $this->createExpandedTermsTable($setup);
         $this->createExpansionReferenceTable($setup);
     }
     if (version_compare($context->getVersion(), '1.0.0', '<')) {
         $this->appendIsActiveColumn($setup);
     }
     $setup->endSetup();
 }
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     /** @var CustomerSetup $customerSetup */
     $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
     if (version_compare($context->getVersion(), '2.0.6', '<')) {
         $this->upgradeVersionTwoZeroSix($customerSetup);
     }
     if (version_compare($context->getVersion(), '2.0.1', '<')) {
         $this->upgradeVersionTwoZeroOne($customerSetup);
     }
     if (version_compare($context->getVersion(), '2.0.2') < 0) {
         $this->upgradeVersionTwoZeroTwo($customerSetup);
     }
     if (version_compare($context->getVersion(), '2.0.3', '<')) {
         $this->upgradeVersionTwoZeroThree($customerSetup);
     }
     if (version_compare($context->getVersion(), '2.0.4', '<')) {
         $this->upgradeVersionTwoZeroFour($customerSetup);
     }
     if (version_compare($context->getVersion(), '2.0.5', '<')) {
         $this->upgradeVersionTwoZeroFive($customerSetup, $setup);
     }
     if (version_compare($context->getVersion(), '2.0.6', '<')) {
         $setup->getConnection()->delete($setup->getTable('customer_form_attribute'), ['form_code = ?' => 'checkout_register']);
     }
     if (version_compare($context->getVersion(), '2.0.7', '<')) {
         $this->upgradeVersionTwoZeroSeven($customerSetup);
         $this->upgradeCustomerPasswordResetlinkExpirationPeriodConfig($setup);
     }
     $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
     $indexer->reindexAll();
     $this->eavConfig->clear();
     $setup->endSetup();
 }
Ejemplo n.º 13
0
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     //No previous version found, installation, InstallSchema was just executed
     if (!$context->getVersion()) {
     }
     //code to upgrade to 2.0.1
     if (version_compare($context->getVersion(), '2.0.1') < 0) {
         $this->createPagSeguroOrdersTable($setup);
         $this->integratePagSeguroAndOrdersGrid($setup);
         $this->cleanUiBookmark($setup);
     }
     $setup->endSetup();
 }
Ejemplo n.º 14
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '2.0.0.1') < 0) {
         $connection = $setup->getConnection();
         $connection->addIndex($setup->getTable('customer_visitor'), $setup->getIdxName('customer_visitor', ['last_visit_at']), ['last_visit_at']);
     }
     if (version_compare($context->getVersion(), '2.0.1', '<')) {
         $setup->getConnection()->addColumn($setup->getTable('customer_eav_attribute'), 'is_used_in_grid', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'unsigned' => true, 'nullable' => false, 'default' => '0', 'comment' => 'Is Used in Grid']);
         $setup->getConnection()->addColumn($setup->getTable('customer_eav_attribute'), 'is_visible_in_grid', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'unsigned' => true, 'nullable' => false, 'default' => '0', 'comment' => 'Is Visible in Grid']);
         $setup->getConnection()->addColumn($setup->getTable('customer_eav_attribute'), 'is_filterable_in_grid', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'unsigned' => true, 'nullable' => false, 'default' => '0', 'comment' => 'Is Filterable in Grid']);
         $setup->getConnection()->addColumn($setup->getTable('customer_eav_attribute'), 'is_searchable_in_grid', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'unsigned' => true, 'nullable' => false, 'default' => '0', 'comment' => 'Is Searchable in Grid']);
     }
     $setup->endSetup();
 }
Ejemplo n.º 15
0
 /**
  * Upgrades DB schema for a module
  *
  * @param SchemaSetupInterface   $setup
  * @param ModuleContextInterface $context
  * @return void
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '1.0.1', '<')) {
         $setup->getConnection()->addColumn($setup->getTable('fastgento_locator'), 'image', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Location image attribute']);
     }
     if (version_compare($context->getVersion(), '1.0.2', '<')) {
         /**
          * Drop entity Id columns
          */
         $setup->getConnection()->dropColumn($setup->getTable('fastgento_locator'), 'image');
         $setup->getConnection()->addColumn($setup->getTable('fastgento_locator'), 'image', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Location image attribute']);
     }
     $setup->endSetup();
 }
Ejemplo n.º 16
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $installer = $setup;
     $connection = $installer->getConnection();
     if (version_compare($context->getVersion(), '1.0.1') < 0) {
         $connection->dropTable($installer->getTable('mst_blog_author'));
         $table = $installer->getConnection()->newTable($installer->getTable('mst_blog_author'))->addColumn('author_id', Table::TYPE_INTEGER, null, ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'], 'Author Id')->addColumn('user_id', Table::TYPE_INTEGER, null, ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'], 'User Id')->addColumn('display_name', Table::TYPE_TEXT, 255, ['nullable' => true], 'Display name')->addColumn('image', Table::TYPE_TEXT, 255, ['nullable' => true], 'Image')->addColumn('bio', Table::TYPE_TEXT, null, ['nullable' => true], 'Bio')->addForeignKey($installer->getFkName('mst_blog_author', 'user_id', 'admin_user', 'user_id'), 'user_id', $installer->getTable('admin_user'), 'user_id', Table::ACTION_CASCADE)->setComment('Authors');
         $installer->getConnection()->createTable($table);
     }
     if (version_compare($context->getVersion(), '1.0.2') < 0) {
         $connection->dropTable($installer->getTable('mst_blog_post_product'));
         $table = $installer->getConnection()->newTable($installer->getTable('mst_blog_post_product'))->addColumn('post_id', Table::TYPE_INTEGER, null, ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'], 'Post ID')->addColumn('product_id', Table::TYPE_INTEGER, null, ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'], 'Product ID')->addColumn('position', Table::TYPE_INTEGER, null, ['unsigned' => true, 'nullable' => true, 'default' => '0'], 'Position')->addIndex($installer->getIdxName('mst_blog_post_product', ['post_id']), ['post_id'])->addIndex($installer->getIdxName('mst_blog_post_product', ['product_id']), ['product_id'])->addForeignKey($installer->getFkName('mst_blog_post_product', 'product_id', 'catalog_product_entity', 'entity_id'), 'product_id', $installer->getTable('catalog_product_entity'), 'entity_id', Table::ACTION_CASCADE)->addForeignKey($installer->getFkName('mst_blog_post_product', 'post_id', 'mst_blog_post_entity', 'entity_id'), 'post_id', $installer->getTable('mst_blog_post_entity'), 'entity_id', Table::ACTION_CASCADE)->setComment('Blog Post To Product Linkage Table');
         $installer->getConnection()->createTable($table);
     }
 }
Ejemplo n.º 17
0
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '2.0.1', '<')) {
         /**
          * install vat exempt tax class
          */
         $data = [['class_name' => 'Vatexempt Class', 'class_type' => \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT]];
         foreach ($data as $row) {
             $setup->getConnection()->insertForce($setup->getTable('tax_class'), $row);
         }
         /**
          * install vat exempt tax rate
          */
         $data = [['tax_country_id' => 'US', 'tax_region_id' => '*', 'tax_postcode' => '*', 'code' => 'Vat Exempt', 'rate' => '0.00']];
         foreach ($data as $row) {
             $setup->getConnection()->insertForce($setup->getTable('tax_calculation_rate'), $row);
         }
         /**
          * install vat exempt tax rule
          */
         $this->_executor->exec($this->_installer);
     }
     $setup->endSetup();
 }
Ejemplo n.º 18
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $installer = $setup;
     $setup->startSetup();
     $version = $context->getVersion();
     $connection = $setup->getConnection();
     if (version_compare($version, '2.0.1') < 0) {
         foreach (['magefan_blog_post_relatedpost', 'magefan_blog_post_relatedproduct'] as $tableName) {
             // Get module table
             $tableName = $setup->getTable($tableName);
             // Check if the table already exists
             if ($connection->isTableExists($tableName) == true) {
                 $columns = ['position' => ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, 'nullable' => false, 'comment' => 'Position']];
                 foreach ($columns as $name => $definition) {
                     $connection->addColumn($tableName, $name, $definition);
                 }
             }
         }
         $connection->addColumn($setup->getTable('magefan_blog_post'), 'featured_img', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'nullable' => true, 'comment' => 'Thumbnail Image']);
     }
     if (version_compare($version, '2.2.0') < 0) {
         /* Add author field to posts tabel */
         $connection->addColumn($setup->getTable('magefan_blog_post'), 'author_id', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, 'nullable' => true, 'comment' => 'Author ID']);
         $connection->addIndex($setup->getTable('magefan_blog_post'), $setup->getIdxName($setup->getTable('magefan_blog_post'), ['author_id']), ['author_id']);
     }
     if (version_compare($version, '2.2.5') < 0) {
         /* Add layout field to posts and category tabels */
         foreach (['magefan_blog_post', 'magefan_blog_category'] as $table) {
             $table = $setup->getTable($table);
             $connection->addColumn($setup->getTable($table), 'page_layout', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'nullable' => true, 'comment' => 'Post Layout']);
             $connection->addColumn($setup->getTable($table), 'layout_update_xml', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => '64k', 'nullable' => true, 'comment' => 'Post Layout Update Content']);
             $connection->addColumn($setup->getTable($table), 'custom_theme', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 100, 'nullable' => true, 'comment' => 'Post Custom Theme']);
             $connection->addColumn($setup->getTable($table), 'custom_layout', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'nullable' => true, 'comment' => 'Post Custom Template']);
             $connection->addColumn($setup->getTable($table), 'custom_layout_update_xml', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => '64k', 'nullable' => true, 'comment' => 'Post Custom Layout Update Content']);
             $connection->addColumn($setup->getTable($table), 'custom_theme_from', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_DATE, 'nullable' => true, 'comment' => 'Post Custom Theme Active From Date']);
             $connection->addColumn($setup->getTable($table), 'custom_theme_to', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_DATE, 'nullable' => true, 'comment' => 'Post Custom Theme Active To Date']);
         }
     }
     if (version_compare($version, '2.3.0') < 0) {
         /* Add meta title field to posts tabel */
         $connection->addColumn($setup->getTable('magefan_blog_post'), 'meta_title', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'nullable' => true, 'comment' => 'Post Meta Title', 'after' => 'title']);
         /* Add og tags fields to post tabel */
         foreach (['type', 'img', 'description', 'title'] as $type) {
             $connection->addColumn($setup->getTable('magefan_blog_post'), 'og_' . $type, ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'nullable' => true, 'comment' => 'Post OG ' . ucfirst($type), 'after' => 'identifier']);
         }
         /* Add meta title field to category tabel */
         $connection->addColumn($setup->getTable('magefan_blog_category'), 'meta_title', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'nullable' => true, 'comment' => 'Category Meta Title', 'after' => 'title']);
         /**
          * Create table 'magefan_blog_tag'
          */
         $table = $setup->getConnection()->newTable($setup->getTable('magefan_blog_tag'))->addColumn('tag_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['identity' => true, 'nullable' => false, 'primary' => true], 'Tag ID')->addColumn('title', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, ['nullable' => true], 'Tag Title')->addColumn('identifier', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 100, ['nullable' => true, 'default' => null], 'Tag String Identifier')->addIndex($setup->getIdxName('magefan_blog_tag', ['identifier']), ['identifier'])->setComment('Magefan Blog Tag Table');
         $setup->getConnection()->createTable($table);
         /**
          * Create table 'magefan_blog_post_tag'
          */
         $table = $setup->getConnection()->newTable($setup->getTable('magefan_blog_post_tag'))->addColumn('post_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['nullable' => false, 'primary' => true], 'Post ID')->addColumn('tag_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['nullable' => false, 'primary' => true], 'Tag ID')->addIndex($setup->getIdxName('magefan_blog_post_tag', ['tag_id']), ['tag_id'])->addForeignKey($setup->getFkName('magefan_blog_post_tag', 'post_id', 'magefan_blog_post', 'post_id'), 'post_id', $setup->getTable('magefan_blog_post'), 'post_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE)->addForeignKey($setup->getFkName('magefan_blog_post_tag', 'tag_id', 'magefan_blog_tag', 'tag_id'), 'tag_id', $setup->getTable('magefan_blog_tag'), 'tag_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE)->setComment('Magefan Blog Post To Category Linkage Table');
         $setup->getConnection()->createTable($table);
     }
     $setup->endSetup();
 }
    /**
     * {@inheritdoc}
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     */
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        if (version_compare($context->getVersion(), '1.0.1', '<')) {
            /**
             * update cms page sample
             */
            $pageContent = <<<EOD
test update
EOD;
            $cmsPage = $this->createPage()->load('test-cms-page', 'identifier');
            if (!$cmsPage->getId()) {
                $cmsPageContent = ['title' => 'test update', 'content_heading' => 'test', 'page_layout' => '1column', 'identifier' => 'test-cms-page', 'content' => $pageContent, 'is_active' => 1, 'stores' => [0], 'sort_order' => 0];
                $this->createPage()->setData($cmsPageContent)->save();
            } else {
                $cmsPage->setContent($pageContent)->save();
            }
            /**
             * update cms block sample
             */
            $cmsBlockContent = <<<EOD
cms block sample update
EOD;
            $cmsBlock = $this->createBlock()->load('test_cms_block', 'identifier');
            if (!$cmsPage->getId()) {
                $cmsBlock = ['title' => 'test cms block update', 'identifier' => 'test_cms_block', 'content' => $cmsBlockContent, 'is_active' => 1, 'stores' => 0];
                $this->createBlock()->setData($cmsBlock)->save();
            } else {
                $cmsBlock->setContent($cmsBlockContent)->save();
            }
        }
    }
Ejemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     if (version_compare($context->getVersion(), '1.0.1') < 0) {
         $installer = $setup;
         $installer->startSetup();
         $installer->getConnection()->addColumn($installer->getTable('testimonial'), 'email', array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, 'nullable' => true, 'length' => '1k', 'comment' => 'Email Field'));
         $installer->endSetup();
     }
     if (version_compare($context->getVersion(), '1.0.2') < 0) {
         $installer = $setup;
         $installer->startSetup();
         $installer->getConnection()->addColumn($installer->getTable('testimonial'), 'customer_image', array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, 'nullable' => true, 'length' => '1k', 'comment' => 'Customer Image'));
         $installer->getConnection()->addColumn($installer->getTable('testimonial'), 'store_id', array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, 'nullable' => true, 'comment' => 'Store Id'));
         $installer->endSetup();
     }
 }
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '1.1.2', '<')) {
         // Get module table
         $tableName = $setup->getTable('lr_addresses');
         // Check if the table already exists
         if ($setup->getConnection()->isTableExists($tableName) == true) {
             // Declare data
             $columns = ['country' => ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => false, 'comment' => 'country name']];
             $connection = $setup->getConnection();
             foreach ($columns as $name => $definition) {
                 $connection->addColumn($tableName, $name, $definition);
             }
         }
         // Get module table
         $tableNameExtendedProfile = $setup->getTable('lr_extended_profile_data');
         // Check if the table already exists
         if ($setup->getConnection()->isTableExists($tableNameExtendedProfile) == true) {
             // Declare data
             $columnsAdd = ['no_of_login' => ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => false, 'comment' => 'no of login']];
             $connectionData = $setup->getConnection();
             foreach ($columnsAdd as $name => $definition) {
                 $connectionData->addColumn($tableNameExtendedProfile, $name, $definition);
             }
         }
     }
     $setup->endSetup();
 }
Ejemplo n.º 22
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     if (version_compare($context->getVersion(), '2.0.0.1') < 0) {
         $installer = $setup;
         $installer->startSetup();
         $connection = $installer->getConnection();
         $connection->dropForeignKey($installer->getTable('catalog_product_entity'), 'FK_CAT_PRD_ENTT_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID');
         //Drop entity_type_id column for catalog product entities
         $connection->dropColumn($installer->getTable('catalog_product_entity'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('catalog_product_entity_datetime'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('catalog_product_entity_decimal'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('catalog_product_entity_gallery'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('catalog_product_entity_int'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('catalog_product_entity_text'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('catalog_product_entity_varchar'), 'entity_type_id');
         //Drop entity_type_id column for catalog category entities
         $connection->dropColumn($installer->getTable('catalog_category_entity'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('catalog_category_entity_datetime'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('catalog_category_entity_decimal'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('catalog_category_entity_int'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('catalog_category_entity_text'), 'entity_type_id');
         $connection->dropColumn($installer->getTable('catalog_category_entity_varchar'), 'entity_type_id');
         $installer->endSetup();
     }
 }
Ejemplo n.º 23
0
 /**
  * Upgrades DB schema for a module
  *
  * @param SchemaSetupInterface $setup
  * @param ModuleContextInterface $context
  * @return void
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $installer = $setup;
     $installer->startSetup();
     // Action to do if module version is less than 1.0.0.0
     if (version_compare($context->getVersion(), '1.0.0.0') < 0) {
         #Create table 'maxime_jobs'
         $tableName = $installer->getTable('maxime_job');
         $tableComment = 'Job management on Magento 2';
         $columns = array('entity_id' => array('type' => Table::TYPE_INTEGER, 'size' => null, 'options' => array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), 'comment' => 'Job Id'), 'title' => array('type' => Table::TYPE_TEXT, 'size' => 255, 'options' => array('nullable' => false, 'default' => ''), 'comment' => 'Job Title'), 'type' => array('type' => Table::TYPE_TEXT, 'size' => 255, 'options' => array('nullable' => false, 'default' => ''), 'comment' => 'Job Type (CDI, CDD...)'), 'location' => array('type' => Table::TYPE_TEXT, 'size' => 255, 'options' => array('nullable' => false, 'default' => ''), 'comment' => 'Job Location'), 'date' => array('type' => Table::TYPE_DATE, 'size' => null, 'options' => array('nullable' => false), 'comment' => 'Job date begin'), 'status' => array('type' => Table::TYPE_BOOLEAN, 'size' => null, 'options' => array('nullable' => false, 'default' => 0), 'comment' => 'Job status'), 'description' => array('type' => Table::TYPE_TEXT, 'size' => 2048, 'options' => array('nullable' => false, 'default' => ''), 'comment' => 'Job description'), 'department_id' => array('type' => Table::TYPE_INTEGER, 'size' => null, 'options' => array('unsigned' => true, 'nullable' => false), 'comment' => 'Department linked to the job'));
         $indexes = array('title');
         $foreignKeys = array('department_id' => array('ref_table' => 'maxime_department', 'ref_column' => 'entity_id', 'on_delete' => Table::ACTION_CASCADE));
         #We can use the parameters above to create our table
         // Table creation
         $table = $installer->getConnection()->newTable($tableName);
         // Columns creation
         foreach ($columns as $name => $values) {
             $table->addColumn($name, $values['type'], $values['size'], $values['options'], $values['comment']);
         }
         // Indexes creation
         foreach ($indexes as $index) {
             $table->addIndex($installer->getIdxName($tableName, array($index)), array($index));
         }
         // Foreign keys creation
         foreach ($foreignKeys as $column => $foreignKey) {
             $table->addForeignKey($installer->getFkName($tableName, $column, $foreignKey['ref_table'], $foreignKey['ref_column']), $column, $foreignKey['ref_table'], $foreignKey['ref_column'], $foreignKey['on_delete']);
         }
         // Table comment
         $table->setComment($tableComment);
         // Execute SQL to create the table
         $installer->getConnection()->createTable($table);
     }
     $installer->endSetup();
 }
Ejemplo n.º 24
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     if (version_compare($context->getVersion(), '2.0.1') < 0) {
         $installer = $setup;
         /**
          * update columns created_at and updated_at in sales entities tables
          */
         $tables = ['sales_creditmemo', 'sales_creditmemo_comment', 'sales_invoice', 'sales_invoice_comment', 'sales_order', 'sales_order_item', 'sales_order_status_history', 'sales_payment_transaction', 'sales_shipment', 'sales_shipment_comment', 'sales_shipment_track'];
         /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */
         $connection = $installer->getConnection();
         foreach ($tables as $table) {
             $columns = $connection->describeTable($installer->getTable($table));
             if (isset($columns['created_at'])) {
                 $createdAt = $columns['created_at'];
                 $createdAt['DEFAULT'] = Table::TIMESTAMP_INIT;
                 $createdAt['TYPE'] = Table::TYPE_TIMESTAMP;
                 $connection->modifyColumn($installer->getTable($table), 'created_at', $createdAt);
             }
             if (isset($columns['updated_at'])) {
                 $updatedAt = $columns['updated_at'];
                 $updatedAt['DEFAULT'] = Table::TIMESTAMP_UPDATE;
                 $updatedAt['TYPE'] = Table::TYPE_TIMESTAMP;
                 $connection->modifyColumn($installer->getTable($table), 'updated_at', $updatedAt);
             }
         }
     }
     if (version_compare($context->getVersion(), '2.0.2') < 0) {
         /**
          * Adding 'updated_at' columns.
          */
         $tables = ['sales_shipment_grid', 'sales_invoice_grid', 'sales_creditmemo_grid'];
         foreach ($tables as $table) {
             $table = $setup->getTable($table);
             $setup->getConnection()->addColumn($table, 'updated_at', ['type' => Table::TYPE_TIMESTAMP, 'after' => 'created_at', 'comment' => 'Updated At']);
             $setup->getConnection()->addIndex($table, $setup->getIdxName($table, ['updated_at']), 'updated_at');
         }
         /**
          * Modifying default value of 'updated_at' columns.
          */
         $tables = ['sales_order', 'sales_shipment', 'sales_invoice', 'sales_creditmemo'];
         foreach ($tables as $table) {
             $table = $setup->getTable($table);
             $setup->getConnection()->modifyColumn($table, 'updated_at', ['type' => Table::TYPE_TIMESTAMP, 'default' => Table::TIMESTAMP_INIT_UPDATE]);
         }
     }
 }
Ejemplo n.º 25
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '2.0.1', '<')) {
         $setup->getConnection()->addIndex($setup->getTable('quote_id_mask'), $setup->getIdxName('quote_id_mask', ['masked_id']), ['masked_id']);
     }
     $setup->endSetup();
 }
Ejemplo n.º 26
0
 /**
  * Upgrade the module data.
  *
  * @param ModuleDataSetupInterface $setup   The setup interface
  * @param ModuleContextInterface   $context The module Context
  *
  * @return void
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '1.1.0', '<')) {
         $this->updateVirtualCategoryRootTypeToInt($setup);
     }
     $setup->endSetup();
 }
Ejemplo n.º 27
0
 /**
  * Installs DB schema for a module
  *
  * @param SchemaSetupInterface   $setup   Setup
  * @param ModuleContextInterface $context Context
  *
  * @return void
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '1.1.0', '<')) {
         $this->appendDecimalDisplayConfiguration($setup);
     }
     $setup->endSetup();
 }
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '1.0.1') < 0) {
         $this->createMailDropboxUserTable($setup);
     }
     $setup->endSetup();
 }
Ejemplo n.º 29
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $connection = $setup->getConnection();
     if (version_compare($context->getVersion(), '2.0.1', '<')) {
         $column = ['type' => Table::TYPE_SMALLINT, 'length' => 6, 'nullable' => false, 'comment' => 'Applied mode', 'default' => '0'];
         $connection->addColumn($setup->getTable('checkout_agreement'), 'mode', $column);
     }
 }
Ejemplo n.º 30
0
 /**
  * @inheritdoc
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '2.0.1', '<')) {
         $this->upgradeHash($setup);
     }
     $setup->endSetup();
 }