laravel 中 migration

 

命令:

  php artisan make:model

  

    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title', 100);
            $table->text('content');
            $table->integer('user_id');
            $table->timestamps();
        });
    }

 

  用法详情: 见手册

  案例:去github上找开源的项目看看 migration  别人怎么写的。

 

  migration 出错了, 1076  .。。 767

  utf8 -> 1字符对应一个3字节  767bit ~ 255B

  utf8mb4 -> 1个字符对应4个字节  

 

  解决方法:

      app\Providers\AppServiceProvider.php  /   public function boot() 中添加方法 

      

Schema::defaultStringLength(191);

 

      或者: config / database.php 进行更改字符集 utf8mb4 -> utf8

 

posted @ 2017-08-20 11:26  silvercell  阅读(459)  评论(0)    收藏  举报