Laravel迁移返回无效的SQL [英] Laravel Migration Returning Invalid SQL
问题描述
我正在运行Laravel 6.0.2,升级方法如下:
I am running Laravel 6.0.2 and my migration up method is as follows:
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('first_name');
$table->string('last_name');
$table->string('email')->unique();
$table->string('password');
$table->boolean('admin')->default(false);
$table->boolean('manager')->default(false);
$table->rememberToken();
$table->timestamps();
});
create table `users` (
`id` int unsigned not null auto_increment primary key,
`first_name` varchar(255) not null,
`last_name` varchar(255) not null,
`email` varchar(255) not null,
`password` varchar(255) not null,
`admin` tinyint(1) not null default ('0'),
`manager` tinyint(1) not null default ('0'),
`remember_token` varchar(100) null,
`created_at` timestamp null,
`updated_at` timestamp null
) default character set utf8mb4 collate 'utf8mb4_unicode_ci'
我已经在一个在线语法检查器上运行了该SQL,这在admin tinyint(1) not null default ('0'),
行上给了我错误.
I have run that SQL on an online syntax checker and that is giving me and error on the admin tinyint(1) not null default ('0'),
line.
我不确定这是否是Laravel 6.0.2错误,因为它似乎在该更新之前有效.
I am not sure whether this is a Laravel 6.0.2 bug as it seemed to be working before that update.
有人遇到这个问题并且知道解决方法吗?
Has anyone run into this issue and know of the fix?
推荐答案
好吧,这很容易修复,也很容易忽略.我的猜测是您已经看了太久了.
Well, this is pretty easy to fix and pretty easy to overlook. My guess is you've been looking at it for too long.
您的DEFAULT
不需要括号或引号.引号仅用于字符串,而不是int
,并且只有在它是子查询时才需要使用括号(这不太可能实际起作用,但我没有尝试过).
Your DEFAULT
s don't need parenthesis or the quotes. The quotes are only there for strings, not int
s, and the parens are only needed if it's a subquery (which isn't likely would actually work, but I haven't tried it).
http://www.w3webtutorial.com/mysql/mysql-default -constraint.php
这篇关于Laravel迁移返回无效的SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!