I'm trying to migrate this code into mysql database but keep getting this error message.
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') default character set utf8 collate utf8_unicode_ci' at line 1
public function up()
{
Schema::create('user', function(Blueprint $table)
{
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
$table->integer('projectId')->unsigned();
$table->boolean('isStudent');
$table->boolean('isCompany');
$table->String('img');
});
Schema::create('user', function($table)
{
$table->foreign('projectId')->references('id')->on('project');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('user');
}
}
For the second instance, use Schema::table
For more information, see here: https://stackoverflow.com/a/28007930/938664
public function up()
{
Schema::create('user', function(Blueprint $table)
{
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
$table->integer('projectId')->unsigned();
$table->boolean('isStudent');
$table->boolean('isCompany');
$table->string('img');
$table->foreign('projectId')->references('id')->on('project')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('user');
}
}
try this Schema::table
public function up()
{
Schema::create('user', function(Blueprint $table)
{
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
$table->integer('projectId')->unsigned();
$table->boolean('isStudent');
$table->boolean('isCompany');
$table->String('img');
});
Schema::table('user', function($table)
{
$table->foreign('projectId')->references('id')->on('project');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('user');
} }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With