我正在尝试将此代码迁移到mysql数据库,但不断收到此错误消息.
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');
}
}
解决方法:
对于第二个实例,使用Schema :: table
有关更多信息,请参见此处: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');
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。