vanilophp / shipment

Vanilo Shipment Module (Laravel E-commerce)
MIT License
5 stars 1 forks source link

Can't create table `vanilo`.`shipping_methods` (errno: 150 "Foreign key constraint is incorrectly formed")") #1

Closed towoju5 closed 2 years ago

towoju5 commented 2 years ago

I ran into the following error while running migration

Doctrine\DBAL\Driver\PDO\Exception::("SQLSTATE[HY000]: General error: 1005 Can't create tablevanilo.shipping_methods(errno: 150 "Foreign key constraint is incorrectly formed")")

Schema::create('shipping_methods', function (Blueprint $table) {
    $table->id();
    $table->string('name')->nullable();
    $table->bigInteger('carrier_id')->nullable();
    $table->json('configuration')->nullable();
    $table->timestamps();
    $table->foreign('carrier_id')->references('id')->on('carriers');
});

I had to modify it like below to sort it out. $table->bigInteger('carrier_id')->nullable(); should be $table->unsignedBigInteger('carrier_id')->nullable();

fulopattila122 commented 2 years ago

Thanks for the report. It's odd since it is actively being tested against MySQL in the CI pipeline.

Is it MySQL 8.0? Do you use the module standalone or as part of the framework?

Anyway, it seems to be safer to go the way you suggested, so it'll likely hit the codebase.