I am getting an error while migrating my tables. the error says
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,
start_datedate not null,end_datedate not null,statusenum('' at line 1 (SQL: create tablemodules(idint unsigned not null auto_increment primary key,titlevarchar(191) not null,descriptiontext not null,imageblob null,resourcesjson null,start_datedate not null,end_datedate not null,statusenum('pending', 'start', 'completed') not null default 'pending',user_idint not null,created_attimestamp null,updated_attimestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
my table have following values:
public function up()
{
Schema::create('modules', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('description');
$table->binary('image')->nullable();
$table->json('resources')->nullable();
$table->date('start_date');
$table->date('end_date');
$table->ENUM('status',['pending','start','completed'])->default('pending');
$table->integer('user_id');
$table->timestamps();
});
}
this is my model code:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class modules extends Model
{
protected $fillable = [
'title', 'description','image','resources', 'start_date','end_date','status','user_id',
];
}
can anyone have the solution for this??
As of Laravel, the $table->json() method will try to create an actual JSON field in the database. However, the JSON field was not added to MySQL until MySQL 5.7.8.
Therefore, if you're using a version of MySQL previous to 5.7.8, you need to just create it as a text field
MariaDB new version supported JSON. (Alpha version. Not recommended by Maria to production server. Only testing.)
MariaDB 10.1 do not support JSON
The earlier version of maria db does not support json field type, see the link, https://mariadb.com/resources/blog/json-with-mariadb-10-2/
Please verify your mariadb version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With