我在数据库中创建了两个表。但现在我得到错误来创建另一个。第三张表不能添加到数据库中。但是迁移成功。
我尝试了下面提到的所有想法:
php artisan make:migration create_book_table
php artisan migrate
之后我得到一个错误:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `Admins` add unique `admins_emai
l_unique`(`email`))
然后我尝试了:
php artisan migrate:refresh
但它仍然没有修复。
这是迁移文件
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBookTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('books', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email');
$table->string('phone-number');
$table->string('checkIn');
$table->string('checkOut');
$table->string('Room');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('books');
}
}