Hi everyone,
For one of our projects we have a need to deploy and maintain a demo. As a result I've attempted to setup a set of rake tasks for the job. My goal is have one rake task called "deploy_demo" which purges the database, migrates to the current schema, and loads the db from a set of fixture files in a specified location.
I've written two new tasks the perform portions of this task:
db:purge - purges the db set in RAILS_ENV. load_my_fixtures - loads the db using fixtures from a directory specified by the SRC env var
Then I setup deploy_demo as a task that basically calls db:purge, db:migrate, and then load_my_fixtures. The source is below:
-- Start -- desc "This is a task to deploy a demo. It is setup to work in the context of a local machine. It wipes the DB, migrates up to the current version of the schema, and loads fixtures from RAILS_ROOT/db/fixtures/demo"
task :deploy_demo => ["db:purge","db:migrate"] do
# we need to invoke the one in the body so we can set SRC in the environment ENV['SRC'] = "db/fixtures/demo" Rake::Task[:load_my_fixtures].invoke end -- End --
So, I can run each of the component tasks (db:purge, db:migrate: load_my_fixtures) from the command line and they work fine. When I run deploy_demo the db:fixtures task completes without an error but doesn't actually modify the database. Does anyone know why db:migrate would not modify the db when called as a dependency but would from the command line? I've included output from both methods of calling these tasks with --trace on.
-- Output from calling each sub-task from command line -- c:\dve\ideeli_trunk\lib\tasks>rake db:purge --trace rake db:purge --trace (in c:/dve/ideeli_trunk) ** Invoke db:purge (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:purge Loaded suite c:/ruby/bin/rake.bat Started
Finished in 0.0 seconds.
0 tests, 0 assertions, 0 failures, 0 errors
c:\dve\ideeli_trunk\lib\tasks>rake db:migrate --trace rake db:migrate --trace (in c:/dve/ideeli_trunk) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment -- create_table("rails_crons") -> 0.1010s -- add_column(:rails_crons, :concurrent, :boolean) -> 0.2100s ** Execute db:migrate == Init: migrating