8
Đây là mã di cư của tôi:Laravel 4 Migration - Không thể thêm ràng buộc khoá ngoại
public function up()
{
Schema::create('foos', function(Blueprint $table) {
// Primary key
$table->increments('id');
// Standard
$table->engine = 'InnoDB';
$table->timestamps();
$table->softDeletes();
});
Schema::create('bars', function(Blueprint $table) {
// Primary key
$table->increments('id');
// Define foreign key
$table->integer('foo_id')->unsigned;
// Foreign key contraints
// NOTE: causes "General error: 1215 Cannot add foreign key constraint"
// $table->foreign('foo_id')->references('id')->on('foos');
// Standard
$table->engine = 'InnoDB';
$table->timestamps();
$table->softDeletes();
});
}
public function down()
{
Schema::drop('foos');
Schema::drop('bars');
}
Khi mã để xác định ràng buộc khoá ngoại không được nhận xét ra, tôi nhận được lỗi sau trên dòng lệnh: chung lỗi: 1215 Không thể thêm ràng buộc khóa ngoài.
Bất kỳ ý tưởng nào tôi đang làm sai?
Trong câu nói nổi tiếng của Homer,. Cảm ơn! – StackOverflowNewbie
Đừng đánh bại bản thân - Tôi chỉ có thể trả lời câu hỏi của bạn vì tôi đã làm điều tương tự. :-) – ceejayoz