-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrations not respecting nullable on polygon or point types. #50201
Comments
I have a feeling this will be solved in Laravel v11. Am I correct @hafezdivandari? |
This already works in Laravel 10. Are you trying to add these columns or modify them? Adding// Laravel 10
$table->polygon('geom')->srid(4326); // polygin srid 4326 not null
$table->point('point')->srid(4326); // point srid 4326 not null
// Laravel 11
$table->geometry('geom', 'polygon', 4326); // polygin srid 4326 not null
$table->geometry('point', 'point', 4326); // point srid 4326 not null ModifyingOn Laravel 10, you have to call // Laravel 10
$table->polygon('geom')->srid(4326)->change(); // polygin srid 4326 not null
$table->point('point')->srid(4326)->change(); // point srid 4326 not null
// Laravel 11
$table->geometry('geom', 'polygon', 4326)->change(); // polygin srid 4326 not null
$table->geometry('point', 'point', 4326)->change(); // point srid 4326 not null |
Thanks but I think the nullable bug still exists in L10, what I'm seeing using the laravel 10 example: If I follow the adding steps above it does correctly set point and polygon to "is_nullable NO" however if srid wasn't used then the bug for ->nullable(false) still exists as its not applied to the column correctly and since srid is optional that seems strange to me. In my case I do want to use srid so I can use your adding lines and remove my second step to enforce the srid and nullable status. Thanks |
See above sorry I closed it by accident |
Just not add |
adding $table->polygon('geom')->srid(4326) works. However, if you don't specify a srid then is_nullable can only be set to false with a raw statement. |
It even works if you add |
ok weirdly I can't replicate now either :/ consider it closed and me an idiot unless I can see whats changed |
Laravel Version
10.45
PHP Version
8.3.3
Database Driver & Version
Mysql 8.0.3.3
Description
Nullable == false is not respected when running a new migration for the 2 column types "polygon" and "point" for a Mysql 8 table
$table->polygon('geom')->nullable(false);
$table->point('point')->nullable(false);
Steps To Reproduce
Create a migration with 2 columns:
$table->polygon('geom')->nullable(false);
$table->point('point')->nullable(false);
The columns are not set to nullable in the database.
It works if you run a DB::statement after to alter the columns
DB::statement('ALTER TABLE polygons MODIFY COLUMN geom POLYGON SRID 4326 NOT NULL;');
DB::statement('ALTER TABLE locations MODIFY COLUMN point POINT SRID 4326 NOT NULL;');
which is needed if you want to restrict your point and polygon to use an SRID value for spatial indexing: DB::Statement('CREATE SPATIAL INDEX idx_polygons_geom ON polygons(geom);');
DB::Statement('CREATE SPATIAL INDEX idx_locations_point ON locations(point);');
The text was updated successfully, but these errors were encountered: