This doesn't work:
->addColumn('name', Varien_Db_Ddl_Table::TYPE_TEXT, 200, array(
'nullable' => false,
'collate' => 'utf8mb4_unicode_ci' // doesn't work
), 'Name')
That's because it is ignored:
// lib\Varien\Db\Ddl\Table.php
public function addColumn($name, $type, $size = null, $options = array(), $comment = null)
{
//...
$this->_columns[$upperName] = array(
'COLUMN_NAME' => $name,
'COLUMN_TYPE' => $type,
'COLUMN_POSITION' => $position,
'DATA_TYPE' => $type,
'DEFAULT' => $default,
'NULLABLE' => $nullable,
'LENGTH' => $length,
'SCALE' => $scale,
'PRECISION' => $precision,
'UNSIGNED' => $unsigned,
'PRIMARY' => $primary,
'PRIMARY_POSITION' => $primaryPosition,
'IDENTITY' => $identity,
'COMMENT' => $comment
);
}
// lib\Varien\Db\Adapter\Pdo\Mysql.php
protected function _getColumnDefinition($options, $ddlType = null)
{
//...
return sprintf('%s%s%s%s%s COMMENT %s %s',
$cType,
$cUnsigned ? ' UNSIGNED' : '',
$cNullable ? ' NULL' : ' NOT NULL',
$cDefault !== false ? $this->quoteInto(' default ?', $cDefault) : '',
$cIdentity ? ' auto_increment' : '',
$this->quote($comment),
$after ? 'AFTER ' . $this->quoteIdentifier($after) : ''
);
}
There is no collation in the code.
So, this doesn't work too:
$connection->modifyColumn(
$installer->getTable('geoname/admin2'),
'name',
[
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
'length' => 200,
'nullable' => false,
'collate' => 'utf8mb4_unicode_ci',
'comment' => 'Name'
]
);
The only way is this:
$connection->modifyColumn(
$installer->getTable('geoname/admin2'),
'alternate_names',
'VARCHAR(10000) COLLATE utf8mb4_unicode_ci'
);
Posted by kiatng to OpenMage (2021-03-02 09:31)