Skip to content
This repository
Browse code

Reduce schema format tests

  • Loading branch information...
commit ca69408b49156f98a76adfc03088b6b067fabc61 1 parent 38d26b0
Aaron Patterson authored November 16, 2011
24  activerecord/lib/active_record/railties/databases.rake
@@ -150,8 +150,16 @@ db_namespace = namespace :db do
150 150
   task :migrate => [:environment, :load_config] do
151 151
     ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
152 152
     ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
153  
-    db_namespace["schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
154  
-    db_namespace["structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql
  153
+    db_namespace['_dump'].invoke
  154
+  end
  155
+
  156
+  task :_dump do
  157
+    case ActiveRecord::Base.schema_format
  158
+    when :ruby then db_namespace["schema:dump"].invoke
  159
+    when :sql  then db_namespace["structure:dump"].invoke
  160
+    else
  161
+      raise "unknown schema format #{ActiveRecord::Base.schema_format}"
  162
+    end
155 163
   end
156 164
 
157 165
   namespace :migrate do
@@ -174,8 +182,7 @@ db_namespace = namespace :db do
174 182
       version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
175 183
       raise 'VERSION is required' unless version
176 184
       ActiveRecord::Migrator.run(:up, ActiveRecord::Migrator.migrations_paths, version)
177  
-      db_namespace['schema:dump'].invoke if ActiveRecord::Base.schema_format == :ruby
178  
-      db_namespace['structure:dump'].invoke if ActiveRecord::Base.schema_format == :sql
  185
+      db_namespace['_dump'].invoke
179 186
     end
180 187
 
181 188
     # desc 'Runs the "down" for a given migration VERSION.'
@@ -183,8 +190,7 @@ db_namespace = namespace :db do
183 190
       version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
184 191
       raise 'VERSION is required' unless version
185 192
       ActiveRecord::Migrator.run(:down, ActiveRecord::Migrator.migrations_paths, version)
186  
-      db_namespace['schema:dump'].invoke if ActiveRecord::Base.schema_format == :ruby
187  
-      db_namespace['structure:dump'].invoke if ActiveRecord::Base.schema_format == :sql
  193
+      db_namespace['_dump'].invoke
188 194
     end
189 195
 
190 196
     desc 'Display status of migrations'
@@ -224,16 +230,14 @@ db_namespace = namespace :db do
224 230
   task :rollback => [:environment, :load_config] do
225 231
     step = ENV['STEP'] ? ENV['STEP'].to_i : 1
226 232
     ActiveRecord::Migrator.rollback(ActiveRecord::Migrator.migrations_paths, step)
227  
-    db_namespace['schema:dump'].invoke if ActiveRecord::Base.schema_format == :ruby
228  
-    db_namespace['structure:dump'].invoke if ActiveRecord::Base.schema_format == :sql
  233
+    db_namespace['_dump'].invoke
229 234
   end
230 235
 
231 236
   # desc 'Pushes the schema to the next version (specify steps w/ STEP=n).'
232 237
   task :forward => [:environment, :load_config] do
233 238
     step = ENV['STEP'] ? ENV['STEP'].to_i : 1
234 239
     ActiveRecord::Migrator.forward(ActiveRecord::Migrator.migrations_paths, step)
235  
-    db_namespace['schema:dump'].invoke if ActiveRecord::Base.schema_format == :ruby
236  
-    db_namespace['structure:dump'].invoke if ActiveRecord::Base.schema_format == :sql
  240
+    db_namespace['_dump'].invoke
237 241
   end
238 242
 
239 243
   # desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.'

0 notes on commit ca69408

Please sign in to comment.
Something went wrong with that request. Please try again.