Laravel 创建指定表 migrate

解决方案:
打开创建表的那个 migration 文件,在创建表的方法执行之前加一个判断条件

if (!Schema::hasTable('password_resets')) {
    Schema::create('password_resets', function (Blueprint $table) {
        $table->string('email')->index();
        $table->string('token');
        $table->timestamp('created_at')->nullable();
    });
}

  判断某个表的某个字段是否存在:

Schema::hasColumn('tableName', 'columeName'); 

  

posted @ 2019-12-03 19:17  明明一颗大白菜  阅读(956)  评论(0编辑  收藏  举报
<-- -->