我有一个带有外键的简单laravel迁移。
public function up()
{
Schema::create('smp_posts', function (Blueprint $table) {
$table->increments('id');
$table->integer('project_id')->unsigned();
// Some other stuff
$table->foreign('project_id')->references('id')->on('smp_projects')->onDelete('cascade');
});
}
当我运行迁移命令php artisan migrate:refresh
时。我收到此错误:
Illuminate \ Database \ QueryException:
SQLSTATE [2BP01]:依赖对象仍然存在:7
错误:无法删除表smp_projects,因为其他对象依赖该表 详细信息:对表smp_posts的约束smp_posts_project_id_foreign取决于表smp_projects
通常所有的孩子都应该删除,因为我将onDelete()
设置为层叠。对?怎么了?
答案 0 :(得分:1)
您设置的File ".../venv/lib/python2.7/site-packages/werkzeug/test.py", line 923, in run_wsgi_app
app_rv = app(environ, start_response)
TypeError: function takes exactly 1 argument (2 given)
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a Connection.
选项仅在删除行时适用。如果删除该表时未触发约束,这就是为什么会出现错误。
您应该看一下Postgres文档的Dependency Tracking部分