-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enh] add tableOptions in Migration #20
Comments
to db component? How it look like in code? |
In some of my projects I'm using custom Migration class instead: class Migration extends \yii\db\Migration
{
/**
* @inheritdoc
*/
public function createTable($table, $columns, $options = null)
{
if ($options === null && $this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$options = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
parent::createTable($table, $columns, $options);
}
} |
@pana1990 how should it look like in the config file? |
I use that fragment code as well but if you have any third extension that uses migrations it is not as easy, i have move migrations to my migration path and change yii\db\migration for my custom Migration class i am not sure but i imagine something like this one :
if tableOptions is null it get value by default of dbms (CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB for mysql for example) |
I'd introduce |
I think those setting should be configured in a per driver basis. For example, in console.php:
|
Ver la documentación en https://github.com/yiisoft/yii2-queue/blob/master/docs/guide/driver-db.md En MySQL 5.6 y MariaDB 10.1, por omisión, la longitud máxima de las claves (índices) en InnoDB es de 767 bytes (191 ch). En la migración se define como índice "channel", que es un string, que por omisión se crea como un VARCHAR(255), que con la codificación utf8mb4 supera esa longitud, provocando un Error #1071 - Specified key was too long. Por ello, en la configuración de la base de datos, `innodb_large_prefix` necesita estar activo (ON), y así aceptar hasta 3072 bytes. Además: * `innodb_file_format` deberá ser Barracuda en vez de Antelope * `innodb_file_per_table` debería estar activado * Al crear la tabla, hay que pasar la opción `ROW_FORMAT=DYNAMIC` (ó `COMPRESSED`), porque hasta MySQL 5.7/MariaDB 10.2 por omisión es `COMPACT` o `REDUNDANT`. Ver * https://mariadb.com/kb/en/library/xtradbinnodb-storage-formats * https://mariadb.com/kb/en/library/xtradbinnodb-file-format/ * https://github.com/yiisoft/yii2/issues/14594 Otra migración contiene `renameColumn()`, cuya implementación para MySQL/MariaDB puede no funcionar según el tipo de comillas que devuelva la BD. Ver yiisoft/yii2#14267
Yii use the following code in multiple places :
https://github.com/yiisoft/yii2/blob/master/framework/rbac/migrations/m140506_102106_rbac_init.php#L56
https://github.com/yiisoft/yii2/blob/master/framework/web/migrations/m160313_153426_session_init.php#L26
https://github.com/yiisoft/yii2/blob/master/framework/caching/migrations/m150909_153426_cache_init.php#L44
some extensions as well
https://github.com/dektrium/yii2-user/blob/master/migrations/Migration.php#L39
you like we include this option to global custom
tableOptions
in configuration file?what do you think about it?
The text was updated successfully, but these errors were encountered: