When migrating using the command line, I get this error...
(errno: 150 "Foreign key con straint is incorrectly formed")
And here is my migration code..
public function up()
{
Schema::enableForeignKeyConstraints();
Schema::create('student', function (Blueprint $table) {
$table->integer('student_id')->unsigned()->primary();
$table->string('student_name', 200);
$table->string('student_email', 50);
$table->integer('class_id')->unsigned()->nullable();
$table->string('password', 100);
$table->rememberToken();
$table->timestamps();
});
Schema::table('student', function($table) {
$table->foreign('class_id')->references('class_id')->on('class_tbl');
});
}
I haven't found solutions to this, and I can't figure out what's wrong...
EDIT:
Here is the migration for class_tbl...
public function up()
{
Schema::enableForeignKeyConstraints();
Schema::create('class_tbl', function (Blueprint $table) {
$table->integer('class_id')->unsigned()->primary();
$table->string('course', 10);
$table->string('section', 5);
$table->string('school_year', 10);
$table->integer('prof_id')->unsigned();
});
Schema::table('class_tbl', function($table) {
$table->foreign('prof_id')->references('prof_id')->on('professor');
});
}