1

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the reply. If thats so, i'd prefer to use only phpmyadmin creating and editing database.Also, I do not require any version control for database (for now atleast). most tutorials/articles stress on migrations,schema builder present in Laravel which made me think that its compulsory to have them.
If you are developing by yourself (not in a team), you will be just fine with phpmyadmin, plus you can move to artisan migrations anytime later. It is very true that that even Laravel documentation does not really advertise the benefits or even the possibility of creating and maintaining database structure outside Laravel.
yeah, I'm doing it by myself. Thanks for the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.