0
我有一个引导任务,我打算有db:reset
和db:migrate
作为先决条件。我定义它是这样的:为什么不将db:migrate作为先决条件进行调用?
task :bootstrap => [:environment,:"db:reset",:"db:migrate"] do ...
当我运行它,我得到以下的输出:
** Invoke bs:bootstrap (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:reset (first_time)
** Invoke db:drop (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:drop
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config
** Execute db:create
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
-- create_table("projects", {:force=>true})
-> 0.0770s
-- create_table("users", {:force=>true})
-> 0.1110s
...
** Invoke db:seed (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment
** Execute db:abort_if_pending_migrations
You have 1 pending migrations:
20120109172252 CreateObjectives
Run "rake db:migrate" to update your database then try again.
为什么不db:migrate
被调用,因为它的上市为前提?
是否确定db:reset之前列出的数据不需要迁移挂起,并且在db到达之前失败:migrate? – 2012-01-09 17:37:49
我应该如何确保数据库中没有任何东西?我希望它在启动之前完全清空。 – Geo 2012-01-09 17:39:04