How to change (modify) a column definition for a database table

If you want just to rename a column: How to rename a database column?

Use the changeColumn() or the modifyColumn() method of the \Magento\Framework\DB\Adapter\AdapterInterface:


The difference between the CHANGE COLUMN and MODIFY COLUMN MySQL expressions is explained here: http://stackoverflow.com/a/22858945

Usage examples from the core:



See also: The \Magento\Quote\Setup\UpgradeSchema::upgrade() method can be simplified by using the modifyColumn() instead of changeColumn() method of the \Magento\Framework\DB\Adapter\AdapterInterface because the column need not be renamed.

By default the \Magento\Framework\DB\Adapter\AdapterInterface interface is implemented by the \Magento\Framework\DB\Adapter\Pdo\Mysql class:


See also: