aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-12-19 15:59:55 +0100
committerPiotr Sarnacki <drogus@gmail.com>2010-12-19 15:59:55 +0100
commitc29a4485a2bd13fdf8a062b5078e9e305d3601f5 (patch)
treeec5f46519f44d7c9c0065610151b2eebb8138dc6
parentb50024f2fff8a3da46135d4838fe1cda8cb95ceb (diff)
downloadrails-c29a4485a2bd13fdf8a062b5078e9e305d3601f5.tar.gz
rails-c29a4485a2bd13fdf8a062b5078e9e305d3601f5.tar.bz2
rails-c29a4485a2bd13fdf8a062b5078e9e305d3601f5.zip
Refactoring of application's task in engine.rake
-rw-r--r--railties/lib/rails/tasks/engine.rake43
1 files changed, 23 insertions, 20 deletions
diff --git a/railties/lib/rails/tasks/engine.rake b/railties/lib/rails/tasks/engine.rake
index 593be93797..2f0e7be896 100644
--- a/railties/lib/rails/tasks/engine.rake
+++ b/railties/lib/rails/tasks/engine.rake
@@ -8,53 +8,56 @@ task "load_app" do
end
end
+def app_task(name)
+ task name => [:load_app, "app:db:#{name}"]
+end
+
namespace :db do
- task :reset => [:load_app, :"app:db:reset"]
+ app_task "reset"
desc "Migrate the database (options: VERSION=x, VERBOSE=false)."
- task :migrate => [:load_app, :"app:db:migrate"]
- task :"migrate:up" => [:load_app, :"app:db:migrate:up"]
- task :"migrate:down" => [:load_app, :"app:db:migrate:down"]
- task :"migrate:redo" => [:load_app, :"app:db:migrate:redo"]
- task :"migrate:reset" => [:load_app, :"app:db:migrate:reset"]
+ app_task "migrate"
+ app_task "migrate:up"
+ app_task "migrate:down"
+ app_task "migrate:redo"
+ app_task "migrate:reset"
desc "Display status of migrations"
- task :"migrate:status" => [:load_app, :"app:db:migrate:status"]
+ app_task "migrate:status"
desc 'Create the database from config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config)'
- task :create => [:load_app, :"app:db:create"]
- task :"create:all" => [:load_app, :"app:db:create:all"]
+ app_task "create"
+ app_task "create:all"
desc 'Drops the database for the current Rails.env (use db:drop:all to drop all databases)'
- task :drop => [:load_app, :"app:db:drop"]
- task :"drop:all" => [:load_app, :"app:db:drop:all"]
+ app_task "drop"
+ app_task "drop:all"
desc "Load fixtures into the current environment's database."
- task :"fixtures:load" => [:load_app, :"app:db:fixtures:load"]
+ app_task "fixtures:load"
desc "Rolls the schema back to the previous version (specify steps w/ STEP=n)."
- task :rollback => [:load_app, :"app:db:rollback"]
+ app_task "rollback"
desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
- task :"schema:dump" => [:load_app, :"app:db:schema:dump"]
+ app_task "schema:dump"
desc "Load a schema.rb file into the database"
- task :"schema:load" => [:load_app, :"app:db:schema:load"]
+ app_task "schema:load"
desc "Load the seed data from db/seeds.rb"
- task :seed => [:load_app, :"app:db:seed"]
+ app_task "seed"
desc "Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)"
- task :setup => [:load_app, :"app:db:setup"]
+ app_task "setup"
desc "Dump the database structure to an SQL file"
- task :"structure:dump" => [:load_app, :"app:db:structure:dump"]
+ app_task "structure:dump"
desc "Retrieves the current schema version number"
- task :version => [:load_app, :"app:db:version"]
+ app_task "version"
end
-
def find_engine_path(path)
return if path == "/"