mercredi 11 décembre 2019

Unable To create new table in database

I created two tables in database. But now I get error to create another one. Third table can not add in the database. But migrate successfully.

I tried all those thinks which are mentioned below:

php artisan make:migration create_book_table

php artisan migrate

after that I get an error:


  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`))

Then I tried:

php artisan migrate:refresh

but it's still not fixed.

Here is the migration file


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');
    }
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire