Reputation: 851
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'
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.
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?
Upvotes: 1
Views: 84
Reputation: 2454
Well, this is pretty easy to fix and pretty easy to overlook. My guess is you've been looking at it for too long.
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
Upvotes: 1
Reputation: 4201
In mysql boolean type is tinyint 0 false 1 true ...
$table->boolean('admin')->default(0);
Upvotes: 0