eloquent - 迁移中的默认值变成 SQL 错误
问题描述
我正在尝试将我的代码从 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')
解决方案
推荐阅读
- javascript - 使用来自 API 的信息使用 JS 编辑 html 宽度
- python - Python regex 使用 re.findall( r'( )', string) 选择性地选择数字
- php - laragon 与 xampp 相比有什么缺点吗?
- r - 对于 R 的 mapview 包,我可以将 map.types 显式设置为 NULL 吗?
- tomcat - intellj 将我的 /webapp 代码部署到哪里?
- react-native - React Native 导航 - navigation.navigate 不是一个函数
- javascript - 显示从 POST 请求收到的返回
- javascript - 单击 GoogleDoc 侧边栏上的按钮时,我需要执行一个函数()
- java - 从 res 文件夹加载图像
- javascript - 我正在尝试使用 JavaScript 将代码语法插入 HTML 代码标签,然后使用 Prism 语法高亮编辑标签