Ticket #8389: rebuild_test_db_from_migrations.diff
| File rebuild_test_db_from_migrations.diff, 1.9 kB (added by matthewrudy, 2 years ago) |
|---|
-
activerecord/lib/active_record/base.rb
old new 354 354 # ActiveRecord::Schema file which can be loaded into any database that 355 355 # supports migrations. Use :ruby if you want to have different database 356 356 # adapters for, e.g., your development and test environments. 357 # If :migrations, the schema is not dumped and the database is loaded 358 # directly from the migrations. 357 359 cattr_accessor :schema_format , :instance_writer => false 358 360 @@schema_format = :ruby 359 361 -
railties/lib/tasks/databases.rake
old new 111 111 end 112 112 end 113 113 114 desc 'Rebuild the test database from your migrations' 115 task :rebuild_from_migrations => ["db:test:purge"] do 116 ActiveRecord::Base.establish_connection(:test) 117 ActiveRecord::Schema.verbose = false 118 Rake::Task["db:migrate"].invoke 119 end 120 114 121 desc "Empty the test database" 115 122 task :purge => :environment do 116 123 abcs = ActiveRecord::Base.configurations … … 150 157 desc 'Prepare the test database and load the schema' 151 158 task :prepare => :environment do 152 159 if defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank? 153 Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke 160 task = case ActiveRecord::Base.schema_format 161 when :sql 162 "db:test:clone_structure" 163 when :ruby 164 "db:test:clone" 165 when :migrations 166 "db:test:rebuild_from_migrations" 167 end 168 Rake::Task[task].invoke 154 169 end 155 170 end 156 171 end