aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/lib/tasks/databases.rake23
1 files changed, 12 insertions, 11 deletions
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index 9162be8f30..7d18df1873 100644
--- a/railties/lib/tasks/databases.rake
+++ b/railties/lib/tasks/databases.rake
@@ -16,11 +16,7 @@ namespace :db do
# <<: *defaults
next unless config['database']
# Only connect to local databases
- if %w( 127.0.0.1 localhost ).include?(config['host']) || config['host'].blank?
- create_database(config)
- else
- p "This task only creates local databases. #{config['database']} is on a remote host."
- end
+ local_database?(config) { create_database(config) }
end
end
end
@@ -65,11 +61,7 @@ namespace :db do
# Skip entries that don't have a database key
next unless config['database']
# Only connect to local databases
- if config['host'] == 'localhost' || config['host'].blank?
- drop_database(config)
- else
- p "This task only drops local databases. #{config['database']} is on a remote host."
- end
+ local_database?(config) { drop_database(config) }
end
end
end
@@ -79,6 +71,15 @@ namespace :db do
drop_database(ActiveRecord::Base.configurations[RAILS_ENV || 'development'])
end
+ def local_database?(config, &block)
+ if %w( 127.0.0.1 localhost ).include?(config['host']) || config['host'].blank?
+ yield
+ else
+ puts "This task only modifies local databases. #{config['database']} is on a remote host."
+ end
+ end
+
+
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
task :migrate => :environment do
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
@@ -358,4 +359,4 @@ end
def firebird_db_string(config)
FireRuby::Database.db_string_for(config.symbolize_keys)
-end
+end \ No newline at end of file