To install the Migration Exporter from MySQL Workbench
Install thehttps://github.com/beckenrode/mysql-workbench-export-laravel-5-migrations/blob/master/export-laravel-5-migrations.py from Workbench > Scripting > Install Plugin/Module and browse the `export-laravel-5-migrations.py` file.
Then, go to Workbench > Tools > Catalog > Export Laravel 5 Migration and click on "Save the Migrations to the Folder..."
However got the following error: (Workbench > Help > Show Log File)
Then, review the relationship index and foreign keys relations and amended few foreign keys which are not properly selected the reference columns.
Afterwards, tried generating the migration using above method, ultimately able to generate the migration.
However, found missing foreign keys relationship generated migration files.
To generate Laravel Migrations from MySQL Workbench:
To build the migrations with foreign constrains using following steps:
- Export the model using MySQL Workbench > File > Export > Forward Engineer approach as sample_database.sql file
- Create the database called 'sample_database'.
- Next, Import the sample_database.sql file into the above created database to build tables, which will populate all tables from the script. (you can also directly execute all the scripts from that .sql file instead, from the Query Builder)
Note: Please make sure all the foreign keys relationships are created along with tables, once you find all the relationship are in place.
- Then, go to the MySQL Workbench > Database > Reverse Engineer, and establish the connection and select the database to regenerate the Model (ERD).
This allows the MySQL Workbench to propagate the Tables' objects correctly which supports to generate the migrations.
- Lastly, go to Workbench > Tools > Catalog > Export Laravel 5 Migration and click on "Save the Migrations to the Folder..."
If you already haven't install the Laravel 5 Migration plugin, refer above.