Schema Cache Dump [Rails 4 Countdown to 2013]

Posted on

This post is part of a series of 31 Rails 4 articles being released each day in December 2012.

In production, an initial boot of your Rails application will load the schema of all your models into a schema cache. For those developers who have a large amount of models in their application, Rails 4 has introduced a schema cache dump to speed up the initial application boot time.

To make a dump of your schema, execute the following rake task:

RAILS_ENV=production bundle exec rake db:schema:cache:dump

This will generate a file db/schema_cache.dump, that Rails will use to load the internal state of the SchemaCache instance.

To disable the schema cache dump, add the following to your config/production.rb file:

config.active_record.use_schema_cache_dump = false 

If you would like to clear the schema cache, execute:

RAILS_ENV=production bundle exec rake db:schema:cache:clear

Further Reading


This post is by Kevin Faustino. Kevin is the Chief Craftsman of Remarkable Labs and also the founder of the Toronto Ruby Brigade.


comments powered by Disqus