Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpgradeSchema.php
Go to the documentation of this file.
1 <?php
8 
13 
18 {
23  {
25  $installer->startSetup();
26 
27  if (version_compare($context->getVersion(), '2.0.1') < 0) {
29  ->getConnection()
30  ->modifyColumn('test_table', 'float', ['type' => 'float', 'default' => 29]);
31  }
32  //Create table and check, that Magento can`t delete it
33  if (version_compare($context->getVersion(), '2.0.2') < 0) {
34  $table = $setup->getConnection()->newTable(
35  $setup->getTable('custom_table')
36  )->addColumn(
37  'custom_id',
38  \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
39  null,
40  ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
41  'Custom Id'
42  )->addColumn(
43  'name',
44  \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
45  255,
46  [],
47  'Custom Name'
48  )->setComment(
49  'Custom Table'
50  );
51  $setup->getConnection()->createTable($table);
52  }
53 
54  $installer->endSetup();
55  }
56 }
upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
$setup
Definition: trigger.php:12
$table
Definition: trigger.php:14