New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

konekt/laravel-migration-compatibility

Library to help migrations to figure out whether a related field is int or bigInt
356,001
Install
composer require konekt/laravel-migration-compatibility
Latest Version:1.11.0
PHP:^8.3
Laravel:11 · 12 · 13
Older releases:5 – 10
License:MIT
Last Updated:Apr 17, 2026
Links: GitHub  ·  Packagist
Maintainer: konekt

Laravel Migration Compatibility

Tests Packagist Stable Version Packagist downloads StyleCI MIT Software License

Laravel 5.8 And The BigInt Problem

As of Laravel 5.8, migration stubs use the bigIncrements method on ID columns by default. Previously, ID columns were created using the increments method.

Foreign key columns must be of the same type. Therefore, a column created using the increments method can not reference a column created using the bigIncrements method.

This small change is a big source of problems for packages that define references to the default Laravel user table.

This package helps to solve this problem by extending Laravel's Blueprint class by a method that can detect the actual referenced field type:

class CreateProfilesTable extends Migration
{
    public function up()
    {
        Schema::create('profiles', function (Blueprint $table) {
            $table->increments('id');

            // Make `user_id` field the same type as the `id` field of the `user` table:
            $table->intOrBigIntBasedOnRelated('user_id', Schema::connection(null), 'users.id');

            //...

            $table->foreign('user_id')
                ->references('id')
                ->on('users');
        });
    }
//...

Installation

composer require konekt/laravel-migration-compatibility

Documentation

For detailed usage and examples go to the Documentation or refer to the markdown files in the docs/ folder of this repo.

For the list of changes read the Changelog.

Related Packages

tomzx/laravel-migration

A migration service based on Laravel Database package.

35 5
gguney/rmigration

Reverse Migration for Laravel

3,733 3
colbeh/consts

laravel tables constant generator

156 1
ajcastro/fk-adder

Lets you add foreign keys in a swift! Foreign key adder in laravel migration.

3,645 4
windwardrail/fast-migrations

Make tests run faster by using fresh copies of pre-migrated databases.

7 0

Version History

Version Released PHP Laravel License
1.11.0 ^8.3 ^11.46.2|^12.50|^13.0 MIT
1.10.0 ^8.1 ^10.0|^11.0|^12.0 MIT
1.9.0 ^8.0 ^10.0|^11.0 MIT
1.8.0 ^8.0 ^9.0|^10.0|^11.0 MIT
1.7.0 ^8.0 ^9.0|^10.0 MIT