-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Can't create a not nullable generated column in mysql #31398
Copy link
Copy link
Closed
Description
- Laravel Version: 6.14.0
- PHP Version: 7.4.0
- Database Driver & Version: MySQL 8.0.19
Description:
When creating a generated column in my migration, the nullable() modifier method has no effect on the column that is created. It looks like this was disabled to fix an issue back in 5.3 but hasn't been re-enabled now that MySQL supports it.
Steps To Reproduce:
The Migration
class CreateAddressesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('addresses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->decimal('latitude');
$table->decimal('longitude');
$table->point('location', 4326)->nullable(false)->storedAs('Point(`latitude`, `longitude`)');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('addresses');
}
}
Running this migration, if you inspect the database you will see that the location column is nullable. So if you try and add a spatial index on the location column, you will get an error that you can't create the index on a column that is allowed to be null
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.