Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 为什么不是';t db:迁移是否作为先决条件被调用?_Ruby On Rails_Ruby_Rake - Fatal编程技术网

Ruby on rails 为什么不是';t db:迁移是否作为先决条件被调用?

Ruby on rails 为什么不是';t db:迁移是否作为先决条件被调用?,ruby-on-rails,ruby,rake,Ruby On Rails,Ruby,Rake,我有一个引导任务,我打算将db:reset和db:migrate作为先决条件。我是这样定义的: task :bootstrap => [:environment,:"db:reset",:"db:migrate"] do ... 当我运行它时,我得到以下输出: ** Invoke bs:bootstrap (first_time) ** Invoke environment (first_time) ** Execute environment ** Invoke db:reset (f

我有一个引导任务,我打算将
db:reset
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:reset将使用db:schema:load来使用db/schema.rb文件来重置数据库,所以实际上不需要运行迁移


您可以改为将db:migrate放在db:reset之前——这将运行迁移,更新schema.rb文件,以便db:reset在重置数据库时使用更新的版本(从而避免挂起的迁移错误).

您是否确定在db:migrate之前列出的db:reset不要求任何迁移处于挂起状态且在到达db:migrate之前失败?我如何确保数据库中没有任何内容?我希望它在引导之前是完全空的。