Using migrations to delete table with foreign key

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

    You can do that thing very easily if you added cascade on the foeign key when creating the table. If you did it, then you can remove the table very easily without something like this for PostgreSQL.

    DB::statement("drop table if exists tableName cascade");
    

    All you have to do is to put the statement for SQL table in the raw format.

    0 讨论(0)
提交回复
热议问题