Is there any way to generate migrations based on an existing Laravel database?

2

When I used Python's Django, I was surprised by the inspectdb command, which is able to generate the models based on an existing database.

In Laravel, we have the migrations to be able to work with the database, and I find a clean and organized way to keep changes to the bank of a project.

However, in Laravel, by default, migrations are always created manually, and usually the tutorials I see always indicate that they should be used from the beginning of project development.

I came up with a new need: I have a dump of a database and would like to transform it into migrations from Laravel.

Is there a library in Laravel that enables reverse engineering of a database, transforming it into migrations from Laravel itself?

That is, I want a library to read the existing database and manage migrations based on that structure.

I would like an answer for this, if possible, for Laravel 4 and 5 (as I still use 4).

Note : I would not like solutions like importing DUMP for migration and running it. Not ideal for the case that I need.

    
asked by anonymous 06.09.2018 / 15:03

1 answer

2

There is a library called Migrations Generator that reads an existing database and generates the corresponding migrations and it inclusive supports Laravel 4.

I did a simple test using Laravel 5.6, with the bank in Mariadb and it correctly generated all the columns of each table, but there is one however. I realized that relationships were not generated.

Anyway, it's worth looking at and testing.

    
07.09.2018 / 21:38