PHPackages                             n3xt0r/laravel-migration-generator - 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. n3xt0r/laravel-migration-generator

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

n3xt0r/laravel-migration-generator
==================================

create migrations from database

9.0.0(1mo ago)4339—0%[1 PRs](https://github.com/N3XT0R/laravel-migration-generator/pulls)MITPHPPHP ^8.3CI passing

Since May 5Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/N3XT0R/laravel-migration-generator)[ Packagist](https://packagist.org/packages/n3xt0r/laravel-migration-generator)[ RSS](/packages/n3xt0r-laravel-migration-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (10)Versions (42)Used By (0)

Laravel Migration Generator
===========================

[](#laravel-migration-generator)

[![CI](https://github.com/N3XT0R/laravel-migration-generator/actions/workflows/ci.yml/badge.svg)](https://github.com/N3XT0R/laravel-migration-generator/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/5fe1da9d0154b4d3496a85116a8a3fb0c0217898ef0f0934eaa47e346b613942/68747470733a2f2f706f7365722e707567782e6f72672f6e33787430722f6c61726176656c2d6d6967726174696f6e2d67656e657261746f722f762f737461626c65)](https://packagist.org/packages/n3xt0r/laravel-migration-generator)[![Code Coverage](https://camo.githubusercontent.com/b52edc37e2654d0811fd8331e87639d7296542170ad10baf430d739d2e90b555/68747470733a2f2f716c74792e73682f6261646765732f64616664336638322d363634362d343761652d613733652d3330303764323766643637642f746573745f636f7665726167652e737667)](https://qlty.sh/gh/N3XT0R/projects/laravel-migration-generator)[![Maintainability](https://camo.githubusercontent.com/0466fad69202532f3f00c45cf4bea4e6e978ea33c553ffb6376dbd33724cc414/68747470733a2f2f716c74792e73682f6261646765732f64616664336638322d363634362d343761652d613733652d3330303764323766643637642f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/N3XT0R/projects/laravel-migration-generator)[![License](https://camo.githubusercontent.com/acc5c450c63c9077a26a30665c46be00c920b7a6ad650f628b7eb9f6125729b8/68747470733a2f2f706f7365722e707567782e6f72672f6e33787430722f6c61726176656c2d6d6967726174696f6e2d67656e657261746f722f6c6963656e7365)](https://packagist.org/packages/n3xt0r/laravel-migration-generator)[![Docs](https://camo.githubusercontent.com/f7df61f0d71f58fbe325ad17523e32e2e77bb19d826a0e6d84c77d4179dc76e7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d72656164746865646f63732d626c7565)](https://laravel-migration-generator.readthedocs.io/)[![DB Support](https://camo.githubusercontent.com/72790c74f3b89db55486a41b3060525567a67e177da3c27f2d355b9bfde19fdd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4461746162617365253230537570706f72742d4d7953514c2532302532462532304d617269614442253230253743253230506f737467726553514c2532302537432532304d5353514c2d626c756576696f6c6574)](https://laravel-migration-generator.readthedocs.io/)[![Total Downloads](https://camo.githubusercontent.com/3e71d3e12cb0be6892642625d5ef64f2ba106598e70f81ceaeb97e7198b4f37b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e33787430722f6c61726176656c2d6d6967726174696f6e2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/n3xt0r/laravel-migration-generator)

> 🧱 **Original project launched in May 2020. Recently reactivated and extended with full CI coverage and support for PostgreSQL, MariaDB, MSSQL and MySQL 8.**
>
> ✅ **CI:** Successfully tested across **MySQL 5.7/8.0**, **PostgreSQL 15**, and **MSSQL 2022** – on **Laravel 12-13**and **PHP 8.3–8.5**.

📦 Overview
----------

[](#-overview)

**Laravel Migration Generator**
*A powerful CLI tool to generate Laravel migration files from an existing MySQL, PostgreSQL or MSSQL database.*

This tool provides a structured and extensible approach to reverse‑engineering database schemas into Laravel‑compatible migration files. It supports foreign key constraints, correct dependency order and customizable mapping logic – enabling seamless integration into both legacy and modern Laravel projects (Laravel 5–13 supported).

✨ Features
----------

[](#-features)

- ✅ Detects tables, columns, indexes and foreign keys with precision
- 🔄 Automatically orders migrations to maintain referential integrity
- 🧱 Extensible design via modular definition/mapping architecture
- 🧩 Supports Laravel 5 to 12 (EOL versions maintained in read‑only mode)
- 🛠 Clean, testable and maintainable codebase
- 🧠 Optional schema normalization (via `--normalizer=`), including:
    - Synthetic primary keys for legacy tables with composite keys
    - Automatic preservation of uniqueness constraints
    - Better Eloquent compatibility for complex schemas

🔍 Feature Comparison
--------------------

[](#-feature-comparison)

Feature / ToolThis Package (N3XT0R)kitloongbennett‑treptowXethron🛠️ Supported Databases✅ MySQL, PostgreSQL, MSSQL✅ MySQL, PostgreSQL, MSSQL, SQLite✅ MySQL only✅ MySQL only⚙ Laravel Compatibility✅ 5–13 (version-aware testing)✅ 5–10+⚠️ up to Laravel 11❌ Legacy only🧪 CI/CD with Matrix Testing✅ Full GitHub Actions matrix❌ Partial❌ Partial❌ None🧩 Extensible Mapping Architecture✅ Yes (definition + mapping layers)❌ Monolithic❌ No❌ No🔒 Actively Maintained✅ Yes (since 2023)✅ Yes✅ Partially❌ No🐘 PostgreSQL Support✅ Yes✅ Yes❌ No❌ No🪟 MSSQL Support✅ Yes✅ Yes❌ No❌ No💡 Primary Use Case✅ Modern &amp; legacy DB export⚙️ Feature-rich🧱 MySQL legacy only🕰️ Historical tool> TL;DR: If you need clean, testable, and modern Laravel migration exports across multiple DB engines – this tool is a solid and extensible choice.

📊 Version Compatibility
-----------------------

[](#-version-compatibility)

LaravelPHP VersionGenerator VersionStatus5.x7.2 – 7.41.0.10❌ EOL6.x7.2 – 7.41.0.10❌ EOL7.x7.2 – 8.02.0.0❌ EOL8.x7.3 – 8.03.0.0❌ EOL9.x8.04.0.0❌ EOL10.x8.1 – 8.35.0.0❌ EOL10.x8.1 – 8.38.3.0 &gt;= 8.0.0❌ EOL11.x8.2 – 8.46.0.0❌ EOL11.x8.2 – 8.48.x❌ EOL12.x8.2 – 8.47.0.0❌ EOL12.x8.2 – 8.58.x⚠️ Security fixes only13.x8.3 – 8.59.x✅ Supported> ⚠️ **Important:** Version 8.0.0 introduces breaking API changes for **Laravel 10–12**.
> All supported Laravel versions receive the new features and updated APIs, requiring updates to dependent code.

---

✅ Database Compatibility
------------------------

[](#-database-compatibility)

The generator works with all major engines:

### MySQL

[](#mysql)

VersionStatus5.7✅ Supported8.0✅ Supported### PostgreSQL

[](#postgresql)

VersionStatus15✅ Supported### MSSQL

[](#mssql)

VersionStatus2022-latest✅ Supported> EOL database versions remain functional for legacy compatibility.

⚙ Requirements
--------------

[](#-requirements)

- PHP ≥ 8.3
    - `pdo_mysql`, `pdo_pgsql` or `pdo_sqlsrv` (depending on your database)
- MySQL ≥ 5.7, PostgreSQL 15 or MSSQL 2022

🧰 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require n3xt0r/laravel-migration-generator --dev
```

Laravel will auto-discover the service provider. No manual registration is needed.

For **Lumen**, register the service provider manually in `bootstrap/app.php`:

```
$app->register(\N3XT0R\MigrationGenerator\Providers\MigrationGeneratorServiceProvider::class);
```

🚀 Usage
-------

[](#-usage)

Run the migration generator via Artisan:

```
php artisan migrate:regenerate
```

This command will generate migration files from your existing database schema into the `database/migrations/` folder. The files will be ordered automatically to maintain referential integrity – no manual reordering required.

⚙️ Custom Export Strategy
-------------------------

[](#️-custom-export-strategy)

If the default export does not meet your needs, the generator is fully extensible. You can override the export logic through Laravel's Dependency Injection container.

### 🔧 Configuration

[](#-configuration)

First, publish the configuration file:

```
php artisan vendor:publish --tag=migration-generator-config
```

Edit `config/migration-generator.php` to adjust or override definitions and mappings.

🧩 Export Architecture
---------------------

[](#-export-architecture)

The export process is divided into two customizable layers:

### Definition Classes

[](#definition-classes)

These classes extract schema information into a **universal, internal representation**. This format is decoupled from Laravel and can be reused, extended, or mapped differently.

### Mapping Classes

[](#mapping-classes)

These classes transform the internal representation into **valid Laravel migration code** (PHP). You can override them to adjust formatting, naming conventions, or structure.

🧰 Schema Normalizers
--------------------

[](#-schema-normalizers)

Schema Normalizers are optional pre-processing steps that transform your database schema before migration generation. They can help adapt legacy structures for better Laravel compatibility.

### Available Normalizers

[](#available-normalizers)

NormalizerDescription`pivot`Replaces composite primary keys with a synthetic auto-incrementing `id()` column and converts the original composite key into a named `unique()` constraint. Useful for legacy tables incompatible with Eloquent.### Usage

[](#usage)

Enable a normalizer via CLI:

```
php artisan migrate:regenerate --normalizer=pivot
```

Or configure it in `config/migration-generator.php`:

```
'normalizer' => [
    'enabled' => ['pivot'],
],
```

🧪 Testing
---------

[](#-testing)

To run the tests:

```
# mysql 5.7
DB_CONNECTION=mysql DB_HOST=db_migration DB_PASSWORD=your_password ./vendor/bin/phpunit

# mysql 8
DB_CONNECTION=mysql DB_HOST=mysql8 DB_PASSWORD=your_password ./vendor/bin/phpunit

#postgres
DB_CONNECTION=pgsql DB_HOST=postgres DB_PASSWORD=your_password ./vendor/bin/phpunit

# mssql
DB_CONNECTION=sqlsrv DB_HOST=mssql DB_PASSWORD=your_password ./vendor/bin/phpunit
```

Docker and CI pipelines are already integrated for continuous validation and quality assurance.

### Key CI features include:

[](#key-ci-features-include)

- Dynamic installation of Laravel versions during test runs via Composer.
- Support for PHPUnit 10 and 11, automatically selected per Laravel version.
- Full code coverage reporting with Xdebug and Clover.
- Version-aware assertions adapting test expectations based on Laravel version.

### ℹ️ Composer Compatibility Strategy

[](#ℹ️-composer-compatibility-strategy)

Although the root `composer.json` targets Laravel 12 by default, earlier Laravel versions (10, 11) are tested in CI using dynamic version installation:

```
run: composer require laravel/framework:^${{ matrix.laravel }} --no-interaction --no-update
```

This ensures flexible version handling while keeping the default installation aligned with the latest stable Laravel release.

### 🧪 Version-Aware Assertions

[](#-version-aware-assertions)

Table-based tests (e.g., migration sorting or detection) dynamically adjust expected values based on the Laravel version:

```
$expectedTables = match (true) {
    str_starts_with(Application::VERSION, '10.') => [...],
    default => [...], // Laravel 11+
};
```

📄 License
---------

[](#-license)

This project is licensed under the [MIT License](LICENSE).

🙌 Contributions
---------------

[](#-contributions)

Contributions are welcome! Feel free to open issues or submit pull requests to improve the generator, add new database support or enhance the customization layers.

🔗 Links
-------

[](#-links)

- 📦 [Packagist Package](https://packagist.org/packages/n3xt0r/laravel-migration-generator)
- 🧪 [CI &amp; Test Coverage](https://qlty.sh/gh/N3XT0R/projects/laravel-migration-generator)
- 📘 [Laravel Documentation](https://laravel.com/docs)

This README reflects the repository’s current features, including explicit support for MySQL, PostgreSQL and MSSQL, correct PDO extensions and updated CI information.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance90

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 97.7% 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 ~77 days

Recently: every ~64 days

Total

29

Last Release

52d ago

Major Versions

4.0.2 → 5.0.02025-06-14

5.0.0 → 6.0.02025-06-14

6.0.0 → 7.0.02025-06-14

7.2.0 → 8.0.02025-06-20

8.4.1 → 9.0.02026-03-21

PHP version history (7 changes)1.0.0PHP &gt;=7.2.0

2.0.0PHP ^7.2.5|^8.0

3.0.0PHP ^7.3|^8.0

4.0.0PHP ^8.0

5.0.0PHP ^8.1

6.0.0PHP ^8.2

9.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/8dbd2b0984ee6f62b6c5c3356b0e0cff2f2afa5c98c4d05272eb4356e080d545?d=identicon)[N3XT0R](/maintainers/N3XT0R)

---

Top Contributors

[![N3XT0R](https://avatars.githubusercontent.com/u/1297846?v=4)](https://github.com/N3XT0R "N3XT0R (671 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (16 commits)")

---

Tags

artisancode-generatordatabasedatabase-toolsdevtoollaravel-packagelarravelmariadbmigrationmssqlmysqlphppostgrespostgresqlreverse-enginneringschemalaravelmigrationsphp-8migration-generatorreferential integrity

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/n3xt0r-laravel-migration-generator/health.svg)

```
[![Health](https://phpackages.com/badges/n3xt0r-laravel-migration-generator/health.svg)](https://phpackages.com/packages/n3xt0r-laravel-migration-generator)
```

###  Alternatives

[xethron/migrations-generator

Generates Laravel Migrations from an existing database

3.3k3.3M25](/packages/xethron-migrations-generator)[tpetry/laravel-postgresql-enhanced

Support for many missing PostgreSQL specific features

9982.0M14](/packages/tpetry-laravel-postgresql-enhanced)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

240173.5k2](/packages/dragon-code-laravel-deploy-operations)[umbrellio/laravel-pg-extensions

Extensions for Postgres Laravel

102426.5k1](/packages/umbrellio-laravel-pg-extensions)

PHPackages © 2026

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