To generate / update db/schema.rb even if you use the :sql parameter, you can put it in your Rakefile :
Rake::Task["db:migrate"].enhance do if ActiveRecord::Base.schema_format == :sql Rake::Task["db:schema:dump"].invoke end end
This should be good for IDea and RubyMine.
For others who just want the file to reference it, you can rename it to something like db/schema.rb.backup so that it doesn't get confused. For this:
Rake::Task["db:migrate"].enhance do if ActiveRecord::Base.schema_format == :sql Rake::Task["db:schema:dump"].invoke File.rename(File.expand_path('../db/schema.rb', __FILE__), File.expand_path('../db/schema.rb.backup', __FILE__)) end end
(Note: Using ../ in paths in a Rakefile , because __FILE__ evaluates a path ending in /Rakefile .)
Gary S. weaver
source share