Create migration files in rails from existing mysql table

橙三吉。 提交于 2019-12-30 03:13:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!