So I'm new to laravel, and I'm learning how to use migration. When i did run the command php artisan migrate
only two tables are created users, and migrations. The other table didn't get created and i didn't touch the file at all since I'm learning i wanted to test and see this is the code on the file:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
}
and this is the error that i'm getting on the terminal:
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Illuminate\Database\QueryException
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` ad
d unique `users_email_unique`(`email`))
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:670
666| // If an exception occurs when attempting to run a query, we'll format the error
667| // message to include the bindings with SQL, which will make this exception a
668| // lot more helpful to the developer instead of just the database's errors.
669| catch (Exception $e) {
> 670| throw new QueryException(> 670| throw new QueryException(
671| $query, $this->prepareBindings($bindings), $e
672| );
673| }
674|
+9 vendor frames
10 database/migrations/2014_10_12_000000_create_users_table.php:24
Illuminate\Support\Facades\Facade::__callStatic("create")
+22 vendor frames
33 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\
ConsoleOutput))
and here it is the code for the second file:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire