Using migrations to delete table with foreign key

后端 未结 7 903
不思量自难忘°
不思量自难忘° 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:51

    I also faced these kind of issues. Migration file order is the main issue here. The best way is to create migration files one by one. Main entities should be created first. Migration should be refreshed with every migrate file creation. (with php artisan migrate:refresh)

    According to @abkrim and @Eric

    public function down()
    {
        Schema::disableForeignKeyConstraints();
        Schema::drop('tableName');
        Schema::enableForeignKeyConstraints();
    }
    

提交回复
热议问题