Generate Laravel migration files from existing databases.
composer require romanzipp/laravel-migration-generator
If you use Laravel 5.5+ you are already done, otherwise continue.
Add Service Provider to your app.php
configuration file:
romanzipp\MigrationGenerator\Providers\MigrationGeneratorProvider::class,
Copy configuration to config folder:
$ php artisan vendor:publish --provider="romanzipp\MigrationGenerator\Providers\MigrationGeneratorProvider"
php artisan mg:generate {--connection=}
You will see various new migration files prefixed with the current time & date.
Notice: This package can't guess the order in which migrations will be created. If you've created some foreign keys in your database, be sure to re-order the migration files based on these relations.
- MySQL
- MariaDB
- SQLite (Info on Datatypes)
- Tables
- Columns
- Column modifiers (nullable, default, ...)
- Indexes
- Foreign keys
There are tests with the following matrix.
- PHP
- 7.2
- 7.3
- 7.4
- 8.0
- 8.1
- 8.2
- Databases
- SQLite
- MySQL
- MariaDB
- Composer dependency versions
- latest
- lowest
./vendor/bin/phpunit
Requires a running MySQL / MariaDB server
./vendor/bin/phpunit -c phpunit.mysql.xml
DB_HOST=127.0.0.1 DB_USERNAME=user DB_PASSWORD=secret ./vendor/bin/phpunit -c phpunit.mysql.xml
- MariaDB: The
JSON
MySQL data type is not supported since Doctrine/DBAL interprets this asDoctrine\DBAL\Types\TextType
- MySQL: Doctrine/DBAL can't differentiate between TEXT, LONGTEXT, MEDIUMTEXT