Laravel - Migrations - Default Expressions
The default
modifier accepts a value or an Illuminate\Database\Query\Expression
instance. Using an Expression
instance will prevent Laravel from wrapping the value in quotes and allow you to use database specific functions. One situation where this is particularly useful is when you need to assign default values to JSON columns:
id();
$table->json('movies')->default(new Expression('(JSON_ARRAY())'));
$table->timestamps();
});
}
}
Support for default expressions depends on your database driver, database version, and the field type. Please refer to your database's documentation.