我正在尝试将我的代码从 Laravel 5.8 更新到 Laravel 6.0。当我尝试迁移数据库时,出现 SQL 语法错误。
移民
Schema::create('stocks', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('product_id');
$table->unsignedInteger('initial_price');
$table->unsignedInteger('quantity');
$table->unsignedInteger('price');
$table->string('language')->default("EN");
$table->string('state', 2)->default('MT');
$table->string('idArticleMKM')->nullable(); //idArticle from mkm
$table->foreign('product_id')->references('id')->on('products');
$table->timestamps();
});
错误
SQLSTATE[42000]:语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 '('EN')、
state
varchar(2) not null default ('MT')、idArticleMKM
varchar(1023)' 附近使用正确的语法(SQL:create tablestocks
(id
int unsigned not null auto_increment 主键,product_id
int unsigned not null,initial_price
int unsigned not null,quantity
int unsigned not null,price
int unsigned not null,language
varchar(1023) not null default ('EN'),state
varchar(2) not null default ( 'MT'),idArticleMKM
varchar(1023) null,created_at
timestamp null,updated_at
timestamp null) 默认字符集 utf8mb4 collate 'utf8mb4_unicode_ci')