Using migrations to delete table with foreign key

后端 未结 7 901
不思量自难忘°
不思量自难忘° 2020-12-24 06:25

Im trying to roll back my migrations.

My migrations file uses foreign keys like so

$table->foreign(\'user_one\')->references(\'id\')->on(\'u         


        
7条回答
  •  执笔经年
    2020-12-24 06:32

    I think this is a better way to do it:

    public function down()
    {
        DB::statement('SET FOREIGN_KEY_CHECKS = 0');
        Schema::dropIfExists('tableName');
        DB::statement('SET FOREIGN_KEY_CHECKS = 1');
    }
    

提交回复
热议问题