Question

I'm a beginner in Laravel framework. I had created a MySQL Db using phpmyadmin designer wherein I could easily do relations between foreign keys etc etc.
But Laravel 4 demands using artisan to create migrations and tables. I feel it'll be tedious to replicate the whole DB using commands and writing everything manually. My question here is:

Is it possible to use the existing MySQL database and generate migrations using it, so that, it will replicate all the relations and foreign keys and everything as is?

Was it helpful?

Solution

Using artisanand Schema builder is optional when creating your Laravel table structure and data seeding. Nothing prevents you from creating structure and data with the help of phpmyadmin or mysqlimport, and plugging your Laravel application directly into that database. Laravel will not know how the database structure and data were created, or if any migrations exist.

You could even mix these two approaches: create some structures via migrations and some via phpmyadmin. Bear in mind that version control would, however, be much easier if you stick to a single method.

Regarding the last part of your question: at least I am not aware of any tool that would convert your current database structure and data into Laravel migration + schema builder code. Such a tool would be handy and probably within reasonable amount of work to create.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top