Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add a column after another one in Magento 2
namespace My\Module\Setup;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\UpgradeSchemaInterface;
* @codeCoverageIgnore
class UpgradeSchema implements UpgradeSchemaInterface
* {@inheritdoc}
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
if (version_compare($context->getVersion(), '[SOME_VERSION]', '<')) {
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, // Or any other type
'nullable' => true, // Or false
'comment' => 'Some comment',
'after' => 'some_column_to_place_the_new_one_after'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.