PHPackages                             axn/laravel-pk-int-to-bigint - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. axn/laravel-pk-int-to-bigint

ActiveLibrary[Database &amp; ORM](/categories/database)

axn/laravel-pk-int-to-bigint
============================

Convert DB primary keys and related foreign keys type from INT to BIGINT in a Laravel project

4.0.0(7mo ago)196.7k↓68.6%6[2 issues](https://github.com/AXN-Informatique/laravel-pk-int-to-bigint/issues)MITPHPPHP ^8.4

Since Oct 27Pushed 7mo ago2 watchersCompare

[ Source](https://github.com/AXN-Informatique/laravel-pk-int-to-bigint)[ Packagist](https://packagist.org/packages/axn/laravel-pk-int-to-bigint)[ Docs](https://github.com/AXN-Informatique/laravel-pk-int-to-bigint)[ RSS](/packages/axn-laravel-pk-int-to-bigint/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (2)Versions (13)Used By (0)

Laravel convert primary keys INT to BIGINT
==========================================

[](#laravel-convert-primary-keys-int-to-bigint)

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.

Version Compatibility
---------------------

[](#version-compatibility)

- **Version 4.x**: Laravel 12+ / PHP 8.4+ (uses native Laravel schema methods)
- **Version 3.x**: Laravel 11 / PHP 8.2+ (uses native Laravel schema methods) ⚠️ **Not compatible with Laravel 12**
- **Version 2.x**: Laravel 8-10 / PHP 8.1+ (uses Doctrine DBAL)

How it works
------------

[](#how-it-works)

It proceeds in 4 steps:

1. **Introspection**: Scans the database and verifies the integrity of foreign keys (if an integrity is not respected it stops and indicates it to you)
2. **Drop constraints**: Temporarily drops all foreign key constraints on each table
3. **Convert columns**: Converts INT to BIGINT on primary and foreign key columns on each table (preserving nullable, default values, and auto-increment settings)
4. **Restore constraints**: Restores all foreign key constraints on each table with their original ON DELETE/ON UPDATE actions

Installation
------------

[](#installation)

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
```

Usage
-----

[](#usage)

**⚠️ Important**: First create a dump of your database in case there is a problem.

### Option 1: Run manually

[](#option-1-run-manually)

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
```

### Option 2: With migration

[](#option-2-with-migration)

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
```

What gets converted
-------------------

[](#what-gets-converted)

The package will convert:

- All primary key columns of type INT, TINYINT, SMALLINT, MEDIUMINT to BIGINT
- All foreign key columns of type INT, TINYINT, SMALLINT, MEDIUMINT to BIGINT
- Preserves all column attributes (nullable, default values, auto-increment)
- Preserves all foreign key constraints (ON DELETE, ON UPDATE actions)

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance63

Regular maintenance activity

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 70% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~136 days

Recently: every ~241 days

Total

12

Last Release

214d ago

Major Versions

1.3.2 → 2.0.02022-12-19

2.x-dev → 3.0.02025-11-04

3.0.0 → 4.0.02025-12-03

PHP version history (5 changes)1.0.0PHP ^8.0

1.1.0PHP ^7.4|^8.0

2.0.0PHP ^8.1

3.0.0PHP ^8.2 || ^8.4

4.0.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1314974?v=4)[Axel Neumann](/maintainers/axn)[@axn](https://github.com/axn)

---

Top Contributors

[![forxer](https://avatars.githubusercontent.com/u/407917?v=4)](https://github.com/forxer "forxer (28 commits)")[![lgtaxn](https://avatars.githubusercontent.com/u/23211553?v=4)](https://github.com/lgtaxn "lgtaxn (10 commits)")[![godismyjudge95](https://avatars.githubusercontent.com/u/3847288?v=4)](https://github.com/godismyjudge95 "godismyjudge95 (2 commits)")

---

Tags

databaselaravelpackage

### Embed Badge

![Health badge](/badges/axn-laravel-pk-int-to-bigint/health.svg)

```
[![Health](https://phpackages.com/badges/axn-laravel-pk-int-to-bigint/health.svg)](https://phpackages.com/packages/axn-laravel-pk-int-to-bigint)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[laravel-liberu/laravel-gedcom

A package that converts gedcom files to Eloquent models

782.5k1](/packages/laravel-liberu-laravel-gedcom)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
