I'm trying to migrate some files, but when I try to migrate the "Subject" migrate file, the artisan outputs:
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table nuevosem_laravel
.subjects
(errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table subjects
add constraint subjects_teacher_foreign
foreign key (teacher
) references teachers
(name
))
I'm running Laravel on Xampp 3.2.4
The "teachers" Schema:
Schema::create('teachers', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->string('name');
$table->string('code')->unique();
$table->timestamps();
});
The "subject" Schema:
Schema::create('subjects', function (Blueprint $table) {
$table->string('period');
$table->string('teacher');
$table->foreign('teacher')->references('name')->on('teachers');
$table->integer('nrc')->unsingned();
$table->string('key');
$table->string('section');
$table->enum('type', ['TEO', 'LAB']);
$table->string('schedule');
$table->string('days');
$table->string('classroom');
$table->string('subject');
$table->timestamps();
});
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire