use existing MySQL Database in Laravel 4

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?

Answers


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.


Need Your Help

EmberJS: how to remove records with many-to-many relationship

ember.js many-to-many ember-data

I stumbled across an issue when I tried to remove a record whose model is in many-to-many relationship to another.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.