how to create migration from existing database in laravel

For modern versions of Laravel you should probably use a package like https://github.com/kitloong/laravel-migrations-generator


You could use Jeffrey Way's generator tool for Laravel 4, and do them by hand. It is a very useful tool. https://github.com/JeffreyWay/Laravel-4-Generators (if you are using Laravel 5, use this package instead: https://github.com/laracasts/Laravel-5-Generators-Extended)

Or you could try out one of the following packages, they should convert your existing schema to Laravel migrations. I have not tried them, but have a look:

  • https://github.com/adamkearsley/laravel-convert-migrations

  • https://github.com/barryvdh/laravel-migration-generator

Also, read the following answer in another question, might be useful to you or others: Reverse engineering or Auto-Generations of Entities in Laravel?


I quick wrote this python script to make migration files out of an existing database.

https://github.com/aljorhythm/sql-to-laravel-migrations

After set up, just do

python retrieve-and-convert.py