Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create migration files in rails from existing mysql table

I m developing an application in rails. I have created a table say "student" in mysql. Is there anyway to create its migration file in rails application? I have specified databse name in config/database.yml" and using others table too. But i want to create tables migration file. How can i do it?

like image 809
Sonal S. Avatar asked Apr 23 '13 08:04

Sonal S.


1 Answers

  • Start by referencing your existing MySQL database in database.yml
  • run rake db:schema:dump to generate the schema.rb file
  • Paste the create_table methods from your schema.rb into a new migration, and Voila!
like image 70
zakelfassi Avatar answered Sep 29 '22 10:09

zakelfassi