When trying to set default value for boolean/tinyInteger i get syntax error (1064).
Works fine in previous versions (<= 6.0.1) .
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
Schema::create('test', function (Blueprint $table) {
$table->boolean('test')->default(true);
});
Produces error
Illuminate/Database/QueryException with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('1')) default character set utf8mb4 collate 'utf8mb4_unicode_ci'' at line 1 (SQL: create table `test` (`test` tinyint(1) not null default ('1')) default character set utf8mb4 collate 'utf8mb4_unicode_ci')'
@taylorotwell / @driesvints Confirmed, downgrading to 6.0.1 made my migrations / tests work again
Using default() for anything caused mysql to error out

I also have this problem on my project. This is due to https://github.com/laravel/framework/pull/29878
ping @browner12
can you guys respond with your MySQL versions?
I am running MySQL 5.7.25
seems like this is due to MySQL 5.
I'm hoping we can find a way to make this change backwards compatible over MySQL versions, so we don't have to start adding checks for the version.
My project is running MySQL 5.7.19.
@browner12 What about instead of adding checks for MySQL versions, add checks so that the parentheses are added only when they are really required for the type?
Same problem here. I just updated the homestead box to the very last 8.1.0 version which came with MySQL 5.7.27 and installed the last release (6.0.2) of Laravel.
According to the MySQL 5.7.27 documentation explicit default should not be in parentheses and the BLOB, TEXT, GEOMETRY, and JSON data types cannot be assigned a default value.
https://dev.mysql.com/doc/refman/5.7/en/data-type-defaults.html#data-types-defaults-explicit
According to the MySQL 8.0 documentation the BLOB, TEXT, GEOMETRY, and JSON data types can be assigned a default value only if the value is written as an expression, even if the expression value is a literal:
CREATE TABLE t2 (b BLOB DEFAULT ('abc'));
This is permitted (literal default specified as expression):
CREATE TABLE t2 (b BLOB DEFAULT 'abc');
This produces an error (literal default not specified as expression):
https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html
I think the placement of hard coded parentheses in the MySqlGrammer::modifyDefault (Laravel 6.0.2) was a mistake. Parentheses should be set according to the column type.
```php
protected function modifyDefault(Blueprint $blueprint, Fluent $column)
{
if (! is_null($column->default)) {
return ' default ('.$this->getDefaultValue($column->default).')';
}
}
````
@X-Coder264 the problem is that v5 cannot use the parentheses at all, so it's dependent on the version, not the field type.
I've asked Taylor to revert the commit, and proposed another solution in my original PR.
We're gonna revert this.
We released v6.0.3 which reverts this
Most helpful comment
I also have this problem on my project. This is due to https://github.com/laravel/framework/pull/29878
ping @browner12