外键约束失败

时间:2013-11-10 23:57:01

标签: php database laravel key schema

有人可以仔细检查我的架构,并指出它有什么问题,因为我有这个约束失败错误。

  

1452无法添加或更新子行:外键约束失败

Schema::create('providers', function($table)
    {
      $table->increments('id');
      $table->string('email')->unique();
      $table->string('password');
      $table->string('first_name', 100);
      $table->string('last_name', 100);
      $table->timestamps();
    });

Schema::create('spaces', function($table)
    {
      $table->increments('id');
      $table->unsignedInteger('provider_id');
      $table->foreign('provider_id')->references('id')->on('providers')->onDelete('cascade')->onUpdate('cascade');
      $table->string('email');
      $table->string('name');
      $table->string('address1');
      $table->string('address2');
      $table->string('address3');
      $table->string('town');
      $table->string('county');
      $table->string('postcode');
      $table->string('latitude');
      $table->string('longitude');
      $table->text('description');
      $table->date('available_from');
      $table->date('available_to');
      $table->timestamps();
    });

0 个答案:

没有答案