brad brad - 10 months ago 41
Git Question

Lost my schema.rb! Can it be regenerated?

Due to some deployment issues I stopped tracking schema.rb in git. Somehow I have stuffed this up and somewhere along the way my schema.rb file has disappeared.

Is there a way of regenerating schema.rb from the database or from the migrations? I would prefer not to lose the existing data.

Answer Source

If you run a rake -T it will list all possible rake tasks for your Rails project. One of them is db:schema:dump which will recreate the schema.rb for the Rails app from the database.

bundle exec rake db:schema:dump