Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Vendor\ModuleName\Setup;
- use Magento\Framework\Setup\UpgradeSchemaInterface;
- use Magento\Framework\Setup\ModuleContextInterface;
- use Magento\Framework\Setup\SchemaSetupInterface;
- class UpgradeSchema implements UpgradeSchemaInterface
- {
- public function upgrade(SchemaSetupInterface $setup,
- ModuleContextInterface $context){
- $setup->startSetup();
- if (version_compare($context->getVersion(), '1.0.1') < 0) {
- // Get module table
- $tableName = $setup->getTable('table_name');
- // Check if the table already exists
- if ($setup->getConnection()->isTableExists($tableName) == true) {
- // Declare data
- $columns = [
- 'imagename' => [
- 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
- 'nullable' => false,
- 'comment' => 'image name',
- ],
- ];
- $connection = $setup->getConnection();
- foreach ($columns as $name => $definition) {
- $connection->addColumn($tableName, $name, $definition);
- }
- }
- }
- $setup->endSetup();
- }
- }
Add Comment
Please, Sign In to add comment