2018-06-26 10:12:59 1864次浏览 3条回答 0 悬赏 15 金钱
$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,希望刚使用这个的小伙伴多多注意!

最佳答案

  • 菜鸟鼻涕 发布于 2018-06-27 14:24 举报

    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 条回复
    回复于 2018-06-27 14:56 回复

    嗯,我最后也是这么解决的,先谢谢了

    觉得很赞
  • 回答于 2018-06-26 10:44 举报

    下载一个sqlyog 可以修改引擎的

  • 回答于 2018-07-06 11:36 举报

    这样你就绑定了Mysql数据库了,建议在执行迁移前判断下数据库,MYsql才增加引擎的设置

您需要登录后才可以回答。登录 | 立即注册
皮蛋是好叔叔
见习主管

皮蛋是好叔叔 北京

注册时间:2015-07-25
最后登录:2022-09-14
在线时长:19小时41分
  • 粉丝1
  • 金钱165
  • 威望10
  • 积分455

热门问题