Convert DB primary keys and related foreign keys type from INT to BIGINT in a Laravel project
axn/laravel-pk-int-to-bigint is a Laravel package for convert db primary keys and related foreign keys type from int to bigint in a laravel project.
It currently has 19 GitHub stars and 6.890 downloads on Packagist (latest version 4.0.0).
Install it with composer require axn/laravel-pk-int-to-bigint.
Discover more Laravel packages by axn
or browse all Laravel packages to compare alternatives.
Last updated
This package convert DB primary keys and related foreign keys type from INT to BIGINT in a Laravel project.
This is especially useful for old projects that need to be updated.
Indeed, since Laravel 5.8 the ID columns are by default of type BIGINT. If you install new packages that use this new "standard" you will have trouble creating the foreign keys.
As a result, this package will be of great help to you to modernize an old application.
It proceeds in 4 steps:
Install the package with Composer:
composer require axn/laravel-pk-int-to-bigint
For Laravel 11 (version 3.x):
composer require axn/laravel-pk-int-to-bigint:^3.0
For Laravel 8-10 (version 2.x):
composer require axn/laravel-pk-int-to-bigint:^2.0
⚠️ Important: First create a dump of your database in case there is a problem.
If you want to run the command directly:
php artisan pk-int-to-bigint:transform
You can specify a specific database/schema:
php artisan pk-int-to-bigint:transform --database=my_database
Publish the migration:
php artisan vendor:publish --tag="pk-int-to-bigint-migration"
So you can incorporate it into your deployment workflow with:
php artisan migrate
The package will convert: