laravel-mysql-spatial icon indicating copy to clipboard operation
laravel-mysql-spatial copied to clipboard

Migration from 4.X to 5.0.0 breaks SRID

Open khalyomede opened this issue 2 years ago • 2 comments

I just migrated from 4.X to 5.0.0, my static analyzer noticed there is not more 3rd srid parameter in constructor of Point, but how to specify it then? Is it a default on the model?

Currently this produces this error when I create a factory of my model:

SQLSTATE[HY000]: General error: 3643 The SRID of the geometry does not match the SRID of the column 'geo'. The SRID of the geometry is 0, but the SRID of the column is 4326. Consider changing the SRID of the geometry or the SRID property of the column. (SQL: insert into `locations` (`address`, `geo`, `is_active`, `category_id`, `updated_at`, `created_at`) values ("6706 Alec Hills\nConroyland, TX 79751-2938", ST_GeomFromText(POINT(162.797666 53.388044)), 1, 1, 2021-11-26 16:50:20, 2021-11-26 16:50:20))

And my migration specified the SRID:

use App\Constants\Espg;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateLocationsTable extends Migration
{
  public function up(): void
  {
    Schema::create('locations', function (Blueprint $table) {
      $table->point('geo', Espg::WSG84); // 4326
    });
  }

  public function down(): void
  {
    Schema::dropIfExists('locations');
  }
}

khalyomede avatar Nov 26 '21 17:11 khalyomede

Somehow this package force pushed old code over top of newer code when tagging release 5.0.0. You can see this in the history of tag 4.0.0 showing the Point.php file was updated 2 years ago while in 5.0.0 it is now showing 4 years ago. The 5.0.0 release is a regression release and should not be used until it is tagged with a more stable progressive release. Have to revert to 4.0.0.

dalabarge avatar Jan 14 '22 22:01 dalabarge

Thanks @dalabarge, that's what I ended up doing and I just skipped this package from composer outdated for the moment...

khalyomede avatar Jan 15 '22 10:01 khalyomede