Ale*_*lex 4 php mysql sql-server utf-8 laravel
我正在尝试将此代码迁移到mysql数据库中,但始终收到此错误消息。
SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法有错误;检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行附近使用')默认字符集utf8 collate utf8_unicode_ci'
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');
}
}
Run Code Online (Sandbox Code Playgroud)
对于第二个实例,使用 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');
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6876 次 |
| 最近记录: |