SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'xxx' already exists

字面意思 xxx表已存在.

在使用laravel  写同步结构的时候 最好习惯性写个if语句判定是否存在

// 判断数据表是否存在 Schema::hasTable(‘table‘);// 判断数据表是否有该列Schema::hasColumn(‘table‘, ‘column‘);

 

实例:

public function up(){ Schema::create(‘xxx‘, function (Blueprint $table) { // if (!Schema::hasTable(‘xxx‘)) {         $table->engine=‘innodb‘; $table->tinyInteger(‘status‘)->default(0)->after(‘xxx2‘)->comment(‘状态 0:非 1:是‘); } });}

  

相关文章