问题
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?
回答1:
- 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!
来源:https://stackoverflow.com/questions/16164542/create-migration-files-in-rails-from-existing-mysql-table