🧱 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 10–12 and PHP 8.2–8.4.
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–12 supported).
- ✅ 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
Feature / Tool | This Package (N3XT0R) | kitloong | bennett‑treptow | Xethron |
---|---|---|---|---|
🛠️ Supported Databases | ✅ MySQL, PostgreSQL, MSSQL | ✅ MySQL, PostgreSQL, MSSQL, SQLite | ✅ MySQL only | ✅ MySQL only |
⚙ Laravel Compatibility | ✅ 5–12 (version-aware testing) | ✅ 5–10+ | ❌ 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 & 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.
Laravel/Lumen | PHP Version | Generator Version | Status |
---|---|---|---|
5.x | 7.2 – 7.4 | 1.0.10 | ❌ EOL |
6.x | 7.2 – 7.4 | 1.0.10 | ❌ EOL |
7.x | 7.2 – 8.0 | 2.0.0 | ❌ EOL |
8.x | 7.3 – 8.0 | 3.0.0 | ❌ EOL |
9.x | 8.0 | 4.0.0 | ❌ EOL |
10.x | 8.1 – 8.3 | 5.0.0 | ❌ EOL |
10.x | 8.1 – 8.3 | 8.0.0 | ✅ Supported |
11.x | 8.2 – 8.4 | 6.0.0 | ❌ EOL |
11.x | 8.2 – 8.4 | 8.0.0 | ✅ Supported |
12.x | 8.2 – 8.4 | 7.0.0 | ❌ EOL |
12.x | 8.2 – 8.4 | 8.0.0 | ✅ 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.
The generator works with all major engines:
Version | Status |
---|---|
5.7 | ✅ Supported |
8.0 | ✅ Supported |
Version | Status |
---|---|
15 | ✅ Supported |
Version | Status |
---|---|
2022-latest | ✅ Supported |
EOL database versions remain functional for legacy compatibility.
- PHP ≥ 8.2
pdo_mysql
,pdo_pgsql
orpdo_sqlsrv
(depending on your database)
- MySQL ≥ 5.7, PostgreSQL 15 or MSSQL 2022
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);
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.
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.
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.
The export process is divided into two customizable layers:
These classes extract schema information into a universal, internal representation. This format is decoupled from Laravel and can be reused, extended, or mapped differently.
These classes transform the internal representation into valid Laravel migration code (PHP). You can override them to adjust formatting, naming conventions, or structure.
To run the tests:
# mysql 5.7
DB_CONNECTION=mysql DB_HOST=db_migration DB_PASSWORD=dein_db_passwort ./vendor/bin/phpunit
# mysql 8
DB_CONNECTION=mysql DB_HOST=mysql8 DB_PASSWORD=dein_db_passwort ./vendor/bin/phpunit
#postgres
DB_CONNECTION=pgsql DB_HOST=postgres DB_PASSWORD=dein_db_passwort ./vendor/bin/phpunit
# mssql
DB_CONNECTION=sqlsrv DB_HOST=mssql DB_PASSWORD=dein_db_passwort ./vendor/bin/phpunit
Docker and CI pipelines are already integrated for continuous validation and quality assurance.
This package undergoes continuous integration with GitHub Actions, running tests on an extensive environment matrix covering Laravel, PHP, and MySQL versions to guarantee robust compatibility and stability.
Laravel Version | PHP Versions | MySQL Versions | Number of Jobs |
---|---|---|---|
10 | 8.2, 8.3 | 5.7, 8.0 | 4 |
11 | 8.2, 8.3, 8.4 | 5.7, 8.0 | 6 |
12 | 8.2, 8.3, 8.4 | 5.7, 8.0 | 6 |
Total: 16 unique MySQL jobs plus additional tests for PostgreSQL and MSSQL.
- 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.
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.
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+
};
This project is licensed under the MIT License.
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.
This README reflects the repository’s current features, including explicit support for MySQL, PostgreSQL and MSSQL, correct PDO extensions and updated CI information.