I have created a students table with following attributes but the problem is it doesnot migrate to mysql. What is the problem?
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateStudentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('students', function (Blueprint $table) {
$table->increments('std_id');
$table->string('std_name');
$table->string('std_email')->unique();
$table->string('std_password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('students');
}
}
I deleted migrations table and users table and again migrated it. The following error occured and users and migrations table migrated but not students table.
C:\xampp\htdocs\crud>php artisan migrate
Migration table created successfully.
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key
was too long; max key length is 767 bytes (SQ
L: alter table `users` add unique `users_email_unique`(`email`))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key
was too long; max key length is 767 bytes
what syntax you have in user table? i think you modify your users table
class CreateUsersTable extends Migration
{
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('users');
}
}
public function up()
{
Schema::create('students', function (Blueprint $table) {
$table->increments('id'); or
$table->string('std_id');
$table->string('std_name');
$table->string('std_email')->unique();
$table->string('std_password');
$table->rememberToken();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('students');
}
}