Blockquote SQLSTATE[HY000]: General error: 1005 Can't create table
gps
.#sql-9e4_161
(errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter tablereceivers
add constraintreceivers_hospital_id_foreign
foreign key (hospital_id
) referenceshospitals
(id
))
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamp('dob');
$table->string('profile_image');
$table->string('profession')->nullable();
$table->string('email')->unique();
$table->string('weight');
$table->string('message');
$table->rememberToken();
$table->timestamps();
$table->softDeletes();
});
{
Schema::create('receivers', function (Blueprint $table) {
$table->increments('id');
$table->integer('member_id')->unsigned()->index();
$table->integer('hospital_id')->unsigned()->index();
$table->timestamps();
$table->softDeletes();
$table->foreign('member_id')->references('id')->on('members');
$table->foreign('hospital_id')->references('id')->on('hospitals');
});
{
Schema::create('hospitals', function (Blueprint $table) {
$table->increments('id');
$table->string('h_name');
$table->integer('country_id')->unsigned()->index();
$table->integer('donate_id')->unsigned()->index();
$table->softDeletes();
$table->timestamps();
$table->foreign('country_id')->references('id')->on('countries');
$table->foreign('donate_id')->references('id')->on('donates');
});
{
Schema::create('donates', function (Blueprint $table) {
$table->increments('id');
$table->date('date');
$table->date('last_bleed');
$table->string('quantity');
$table->string('comments');
$table->integer('blood_group_id')->unsigned()->index();
$table->integer('member_id')->unsigned()->index();
$table->timestamps();
$table->softDeletes();
$table->foreign('blood_group_id')->references('id')-
>on('blood_groups');
$table->foreign('member_id')->references('id')->on('members');
$table->timestamps();
});
}