diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-11-16 15:27:47 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-11-16 15:31:37 -0800 |
commit | ca69408b49156f98a76adfc03088b6b067fabc61 (patch) | |
tree | be2c3a19de1b2eb0521438d34a53f760de33e167 /activerecord/lib/active_record/railties | |
parent | 38d26b0cb56d82093889efa95992a35ba3bb9f29 (diff) | |
download | rails-ca69408b49156f98a76adfc03088b6b067fabc61.tar.gz rails-ca69408b49156f98a76adfc03088b6b067fabc61.tar.bz2 rails-ca69408b49156f98a76adfc03088b6b067fabc61.zip |
Reduce schema format tests
Diffstat (limited to 'activerecord/lib/active_record/railties')
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index ee611f6a2a..d19208dd76 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -150,8 +150,16 @@ db_namespace = namespace :db do task :migrate => [:environment, :load_config] do ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil) - db_namespace["schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby - db_namespace["structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql + db_namespace['_dump'].invoke + end + + task :_dump do + case ActiveRecord::Base.schema_format + when :ruby then db_namespace["schema:dump"].invoke + when :sql then db_namespace["structure:dump"].invoke + else + raise "unknown schema format #{ActiveRecord::Base.schema_format}" + end end namespace :migrate do @@ -174,8 +182,7 @@ db_namespace = namespace :db do version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil raise 'VERSION is required' unless version ActiveRecord::Migrator.run(:up, ActiveRecord::Migrator.migrations_paths, version) - db_namespace['schema:dump'].invoke if ActiveRecord::Base.schema_format == :ruby - db_namespace['structure:dump'].invoke if ActiveRecord::Base.schema_format == :sql + db_namespace['_dump'].invoke end # desc 'Runs the "down" for a given migration VERSION.' @@ -183,8 +190,7 @@ db_namespace = namespace :db do version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil raise 'VERSION is required' unless version ActiveRecord::Migrator.run(:down, ActiveRecord::Migrator.migrations_paths, version) - db_namespace['schema:dump'].invoke if ActiveRecord::Base.schema_format == :ruby - db_namespace['structure:dump'].invoke if ActiveRecord::Base.schema_format == :sql + db_namespace['_dump'].invoke end desc 'Display status of migrations' @@ -224,16 +230,14 @@ db_namespace = namespace :db do task :rollback => [:environment, :load_config] do step = ENV['STEP'] ? ENV['STEP'].to_i : 1 ActiveRecord::Migrator.rollback(ActiveRecord::Migrator.migrations_paths, step) - db_namespace['schema:dump'].invoke if ActiveRecord::Base.schema_format == :ruby - db_namespace['structure:dump'].invoke if ActiveRecord::Base.schema_format == :sql + db_namespace['_dump'].invoke end # desc 'Pushes the schema to the next version (specify steps w/ STEP=n).' task :forward => [:environment, :load_config] do step = ENV['STEP'] ? ENV['STEP'].to_i : 1 ActiveRecord::Migrator.forward(ActiveRecord::Migrator.migrations_paths, step) - db_namespace['schema:dump'].invoke if ActiveRecord::Base.schema_format == :ruby - db_namespace['structure:dump'].invoke if ActiveRecord::Base.schema_format == :sql + db_namespace['_dump'].invoke end # desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.' |