Running rake db:migrate without some initializers

走远了吗. 提交于 2019-12-24 18:53:27

问题


I am trying to run jruby -S rake db:migrate, but I do not want to start up a daemon in config/initializers whenever I do a migrate. Is there a way to do this? Up until now, I have just been moving the daemon file to a file with a .bak extension so that rails doesn't load it when I do the migrate.

I suspect that this is a stupid way of doing things. Is there a better way?

Oh and I am running jruby ( if it matters ).


回答1:


When run:

NODAEMON=1 rake db:migrate

In initializer:

unless ENV['NODAEMON']
# ...
end

You can also create separate task for setting NODAEMON, e.g.

task :fast_migrate do
  ENV['NODAEMON'] = '1' # or just set global variable, or some config
  Rake['db:migrate'].invoke
end


来源:https://stackoverflow.com/questions/3485059/running-rake-dbmigrate-without-some-initializers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!