$table->json() generates an error when running migrations.

Posted 3 years ago by EnokViking

Hello, I've encountered an annoying error here while trying to make a json field(mariaDB).

Here's the code

public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('username')->unique();
            $table->string('email')->unique();
            $table->string('password', 60);
            $table->string('verification_token', 30)->nullable();
            // $table->json('settings'); This causes an error, commenting it out solves it
            $table->rememberToken();
            $table->timestamps();
        });
    }
[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 fo  
  r the right syntax to use near 'json not null, `remember_token` varchar(100) null, `created_at` timestamp not nu' at line 1 (SQL: create table `users` (`id` int   
  unsigned not null auto_increment primary key, `username` varchar(255) not null, `email` varchar(255) not null, `password` varchar(60) not null, `verification_tok  
  en` varchar(30) null, `settings` json not null, `remember_token` varchar(100) null, `created_at` timestamp not null, `updated_at` timestamp not null) default cha  
  racter set utf8 collate utf8_unicode_ci)                                                          

I'm using Laravel 5.2, are there any extra steps I need to take?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.