Laravel json virtual columns Mysql vs MariaDB
0 min read ยท 5 July, 2024
To create a json virtual column on laravel migration file we need to use this format:
$table->string('status')->virtualAs("(`data` ->> '$.status')")->index();
But for MariaDB it return an error when run php artisan migration, we need to use it in this format:
$table->string('status')->virtualAs("JSON_VALUE(`data`, '$.status')")->index();