Using migrations to delete table with foreign key

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

    I think this is the most correct approach:

    public function down()
    {
        Schema::table('[table]', function (Blueprint $table) {
            $table->dropForeign('[table]_[column]_foreign');
            $table->dropColumn('[column]');
        });
    }
    

提交回复
热议问题