Migrations 能修改数据表的引擎吗? [ 2.0 版本 ]
$this->createTable($this->table_name, [
'id' => $this->primaryKey(),
'title' => $this->string(100)->defaultValue('')->notNull()->comment('公告标题'),
'content' => $this->text()->comment('公告内容'),
'lang' => $this->string('20')->comment('标题语言'),
'create_at' => $this->timestamp()->comment('创建时间'),
'update_at' => $this->timestamp()->comment('更新时间'),
'close_at' => $this->timestamp()->comment('结束时间'),
]);
皮蛋是好叔叔 补充于 2018-06-26 10:14
创建的时候忘记了指定引擎,默认创建的表是MyISAM,希望刚使用这个的小伙伴多多注意!
最佳答案
-
用
public function safeDown() { $this->dropTable('{{%tableName}}'); }
删除掉,再migrate/create一个
safeUp方法如下public function safeUp() { $this->createTable('{{%tableName}}', [ 'id' => $this->primaryKey(), 'title' => $this->string(100)->defaultValue('')->notNull()->comment('公告标题'), 'content' => $this->text()->comment('公告内容'), 'lang' => $this->string('20')->comment('标题语言'), 'create_at' => $this->timestamp()->comment('创建时间'), 'update_at' => $this->timestamp()->comment('更新时间'), 'close_at' => $this->timestamp()->comment('结束时间'), ], 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'); } }
共 1 条回复菜鸟鼻涕 觉得很赞
其他 2 个回答
皮蛋是好叔叔 北京
注册时间:2015-07-25
最后登录:2022-09-14
在线时长:19小时41分
最后登录:2022-09-14
在线时长:19小时41分
- 粉丝1
- 金钱165
- 威望10
- 积分455