Ruby / Rails - Reverse Migration - DDL to Ruby Cod

2019-04-14 16:05发布

问题:

Any tools in Ruby or Rails that would allow me to extract from database all the table schema and generate Ruby equivalent "DLL" statements?

Something that would allow me to port schema from say Microsoft SQL Server to Postgres, or MySQL to Sqlite.

回答1:

In Rails/ActiveRecord, you can use rake db:schema:dump to generate db/schema.rb, and rake db:schema:load to load it into a database.