Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I export database structure from the db into migration file?

Is there a way to export database structure in the database from the rails application? I believe there is a way to export Data from the db using rake.

rake db:migrate will create tables from migration files. Is there a command that does opposite way so that migration files will be generated from the db?

I have previously built a rails application during 3.0.x version.

I have many more migration files than the actual number of tables in the database because I have some migration file which adds and removes or change the column structure of the database.

Obviously, I can manually change each migration file and change it into migration file with 3.1 standard, but I just want to know if there is a way to export data base structure. (Or, deriving from existing schema file)

like image 849
user482594 Avatar asked Sep 18 '11 01:09

user482594


People also ask

What is SQL schema migration?

In software engineering, a schema migration (also database migration, database change management) refers to the management of version-controlled, incremental and reversible changes to relational database schemas.


1 Answers

Use command rake db:schema:dump, it will do it for you

Edit: You might be interested in this link: http://www.tutorialspoint.com/ruby-on-rails/rails-and-rake.htm

like image 91
datalost Avatar answered Oct 06 '22 00:10

datalost