Support the ongoing development of Laravel.io →
Database Eloquent Installation
Last updated 2 years ago.
0

The correct naming in Laravel should be:

   Schema::create('person', function (Blueprint $table) {
        $table->increments('id');
   });

   Schema::create('student', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('person_id')->unsigned();
        $table->foreign('person_id')->references('id')->on('person');
    });

to answer your problem: since the second schema query runs in a single call, it's trying to put a constraint on a column that does not exist; to correct it split the query in to two parts:

   Schema::create('student', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('person_id')->unsigned();
    });

   Schema::table('student', function (Blueprint $table) {
        $table->foreign('person_id')->references('id')->on('person');
    });
Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Campigott campigott Joined 4 Jan 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.