无法弄清楚如何在Laravel的表上设置正确的onDelete约束。 (我正在和SqLite合作) $table->…->onDelete('cascade'); // works $table->…->onDelete('null || set null'); // neither of them work 我有3个迁移,创build图库表: Schema::create('galleries', function($table) { $table->increments('id'); $table->string('name')->unique(); $table->text('path')->unique(); $table->text('description')->nullable(); $table->timestamps(); $table->engine = 'InnoDB'; }); 创build图片表格: Schema::create('pictures', function($table) { $table->increments('id'); $table->text('path'); $table->string('title')->nullable(); $table->text('description')->nullable(); $table->integer('gallery_id')->unsigned(); $table->foreign('gallery_id') ->references('id')->on('galleries') ->onDelete('cascade'); $table->timestamps(); $table->engine = 'InnoDB'; }); 将图库表格链接到图片: Schema::table('galleries', function($table) { // id of a picture that is […]