this is my error:
General error: 1215 Cannot add foreign key constraint (SQL: alter table `author_book` add constraint `author_book_author_id_foreign` foreign key (`author_id`) references `author` (`id`))
I have table books and author with pivot table:
Schema::create('books', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->string('name');
$table->unsignedInteger('pages');
$table->string('ISBN');
$table->integer('price');
$table->date('published_at');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
author table:
public function up()
{
Schema::create('authors', function (Blueprint $table) {
$table->increments('id');
$table->string('author');
$table->date('birthdate');
$table->timestamps();
});
}
and my pivot table:
$table->increments('id');
$table->unsignedInteger('author_id');
$table->unsignedInteger('book_id');
$table->foreign('author_id')->references('id')->on('author');
$table->foreign('book_id')->references('id')->on('books');
$table->timestamps();
help me please to find error!