之前看了jelly的Laravel VueJs开发知乎
,里面user
数据表中有个字段settings
用的是json
数据类型,数据库迁移文件是这样写的$table->json('settings')->nullable();
,当时用的是Homestead的开发环境,里面的数据库用的是Mysql5.7.19
版本,执行php artisan migrate
命令的时候都是正常OK的。最近一段时间准备把该项目运行在我的虚拟机的lnmp环境上(centos7.3 MariaDB-10.2.6 PHP-7.1.6
),执行php artisan migrate
的时候报出如下错误,应该是我虚拟机里面的数据库版本不支持json数据类型,前往数据库迁移文件把$table->json('settings')->nullable();
注释掉就OK了。这到底是不是MariaDB-10.2.6
的版本问题呢?还是我个人的问题。请大家帮忙解答。谢谢!
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json null, `remember_token` varchar(100) null, `created_at` timestamp null, `upd' at line 1 (SQL: create table `users` (`id` int unsigned not null auto_increment primary key, `nam
e` varchar(255) not null, `email` varchar(255) not null, `password` varchar(255) not null, `avatar` varchar(255) not null, `confirmation_token` varchar(255) not null, `is_active` smallin
t not null default '0', `questions_count` int not null default '0', `answers_count` int not null default '0', `comments_count` int not null default '0', `favorites_count` int not null de
fault '0', `likes_count` int not null default '0', `followers_count` int not null default '0', `followings_count` int not null default '0', `settings` json null, `remember_token` varchar
(100) null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8 collate utf8_unicode_ci)
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use
near 'json null, `remember_token` varchar(100) null, `created_at` timestamp null, `upd' at line 1