Пример #1
0
 /**
  * @param SchemaSetupInterface $setup
  * @return void
  */
 private function addSupportVideoMediaAttributes(SchemaSetupInterface $setup)
 {
     if ($setup->tableExists(Media::GALLERY_VALUE_TO_ENTITY_TABLE)) {
         return;
     }
     /** Add support video media attribute */
     $this->createValueToEntityTable($setup);
     /**
      * Add media type property to the Gallery entry table
      */
     $setup->getConnection()->addColumn($setup->getTable(Media::GALLERY_TABLE), 'media_type', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 32, 'nullable' => false, 'default' => ImageEntryConverter::MEDIA_TYPE_CODE, 'comment' => 'Media entry type']);
     $setup->getConnection()->addColumn($setup->getTable(Media::GALLERY_TABLE), 'disabled', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'unsigned' => true, 'nullable' => false, 'default' => 0, 'comment' => 'Visibility status']);
     /**
      * Drop entity Id columns
      */
     $setup->getConnection()->dropColumn($setup->getTable(Media::GALLERY_TABLE), 'entity_id');
     /**
      * Drop primary index
      */
     $setup->getConnection()->dropForeignKey($setup->getTable(Media::GALLERY_VALUE_TABLE), $setup->getFkName(Media::GALLERY_VALUE_TABLE, 'value_id', Media::GALLERY_TABLE, 'value_id'));
     $setup->getConnection()->dropForeignKey($setup->getTable(Media::GALLERY_VALUE_TABLE), $setup->getFkName(Media::GALLERY_VALUE_TABLE, 'store_id', 'store', 'store_id'));
     $setup->getConnection()->dropIndex($setup->getTable(Media::GALLERY_VALUE_TABLE), 'primary');
     $setup->getConnection()->addColumn($setup->getTable(Media::GALLERY_VALUE_TABLE), 'record_id', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, 'primary' => true, 'auto_increment' => true, 'unsigned' => true, 'nullable' => false, 'comment' => 'Record Id']);
     /**
      * Add index 'value_id'
      */
     $setup->getConnection()->addIndex($setup->getTable(Media::GALLERY_VALUE_TABLE), $setup->getConnection()->getIndexName($setup->getTable(Media::GALLERY_VALUE_TABLE), 'value_id', 'index'), 'value_id');
     $this->addForeignKeys($setup);
 }
Пример #2
0
 /**
  * Upgrades DB schema for a module
  *
  * @param SchemaSetupInterface $setup
  * @param ModuleContextInterface $context
  */
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '1.0.1') < 0) {
         // Get module table
         $tableName = $setup->getTable('sales_order');
         $gridTableName = $setup->getTable('sales_order_grid');
         // Check if the table already exists
         if ($setup->getConnection()->isTableExists($tableName)) {
             // Declare data
             $columns = ['signifyd_score' => ['type' => Table::TYPE_FLOAT, 'default' => null, 'comment' => 'Score'], 'signifyd_guarantee' => ['type' => Table::TYPE_TEXT, 'LENGTH' => 64, 'default' => 'N/A', 'nullable' => false, 'comment' => 'Guarantee Status'], 'signifyd_code' => ['type' => Table::TYPE_TEXT, 'LENGTH' => 255, 'default' => '', 'nullable' => false, 'comment' => 'Code']];
             $connection = $setup->getConnection();
             foreach ($columns as $name => $definition) {
                 $connection->dropColumn($tableName, $name);
                 $connection->addColumn($tableName, $name, $definition);
                 $connection->addColumn($gridTableName, $name, $definition);
             }
         }
     }
     if (version_compare($context->getVersion(), '1.0.2') < 0) {
         if (!$setup->tableExists('signifyd_connect_retries')) {
             $table = $setup->getConnection()->newTable($setup->getTable('signifyd_connect_retries'));
             $table->addColumn('order_increment', Table::TYPE_TEXT, 255, ['nullable' => false, 'primary' => true], 'Order ID')->addColumn('created', Table::TYPE_TIMESTAMP, null, [], 'Creation Time')->addColumn('updated', Table::TYPE_TIMESTAMP, null, [], 'Last Attempt')->setComment('Signifyd Retries');
             $setup->getConnection()->createTable($table);
         }
     }
     if (version_compare($context->getVersion(), '1.3.5') < 0) {
         // Get table Name
         $tableName = $setup->getTable('signifyd_connect_case');
         // Check if the table already exists
         if ($setup->getConnection()->isTableExists($tableName)) {
             // Declare data
             $columns = ['magento_status' => ['type' => Table::TYPE_TEXT, 'LENGTH' => 255, 'default' => 'waiting_submission', 'nullable' => false, 'comment' => 'Magento Status']];
             $connection = $setup->getConnection();
             foreach ($columns as $name => $definition) {
                 $connection->addColumn($tableName, $name, $definition);
             }
         }
     }
     $setup->endSetup();
 }