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
- If you need to rename a column then use the
changeColumn()
method. - If you need not rename the column then use the
modifyColumn()
method.
Usage examples from the core:
By default the \Magento\Framework\DB\Adapter\AdapterInterface
interface is implemented by the \Magento\Framework\DB\Adapter\Pdo\Mysql
class: