问题描述
我正在尝试运行jruby -S rake db:migrate
,但是我不想在每次迁移时在config/initializers
中启动守护程序.有没有办法做到这一点?到目前为止,我只是将守护程序文件移动到扩展名为.bak的文件中,以便在进行迁移时Rails不会加载该文件.
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?
哦,我正在运行jruby
(如果有关系的话).
Oh and I am running jruby
( if it matters ).
推荐答案
运行时:
NODAEMON=1 rake db:migrate
在初始化程序中:
unless ENV['NODAEMON']
# ...
end
您还可以创建用于设置NODAEMON的单独任务,例如
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
这篇关于在没有一些初始化程序的情况下运行rake db:migrate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!