Is rake db: schema: dump recreating schema.rb from migrations or the database itself?

whether

rake db:schema:dump 

to recreate schema.rb from migrations or the database itself?

+46
ruby-on-rails migration schema rake
Sep 28 '10 at 17:30
source share
1 answer

The answer is simple: from the database.

By the way, when you look at the db source code: * tasks (... / activerecord / railties / databases.rake), you can see that the migration tasks call the scheme: dump after startup

 desc "Migrate the database (options: VERSION=x, VERBOSE=false)." task :migrate => :environment do ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby end 

Thus, the migration works so that it changes the database and then generates a schema.rb file.

+69
Sep 28 '10 at 18:13
source share



All Articles