heroku_san Deploy Strategies And Bundle Blunder

23 November 2012

What's annoying about heroku_san is it will run migration all the time. Not cool. Most of the times I don't have any migration to run. Few seconds wasted waiting for the environment to load yet no migration needed.

Good thing heroku_san allows custom deploy strategy. Here's the complete tutorial. Here's my short version. All I want is for the deployment to just push the commit and that's it. No need for migration and restart. So I just cut as paste from the tutorial to /lib/tasks/heroku.rake

  require 'heroku_san'

class MyStrategy < HerokuSan::Deploy::Base def deploy super end end

HerokuSan.project = HerokuSan::Project.new(Rails.root.join("config","heroku.yml"), :deploy => MyStrategy) ...

Come to think of if, I might as well just do this instead:

  require 'heroku_san'

HerokuSan.project = HerokuSan::Project.new(Rails.root.join("config","heroku.yml"), :deploy => HerokuSan::Deploy::Base) ...

Since I'm not adding anything to it. That's it. Now deploying to heroku should not invoke rake db:migrate.

Except, it didn't work. The gotcha? Checkout my Gemfile

  group :development do
    gem 'heroku_san'
    ...
  end

Yeah, no heroku_san on production. I then just add simple check.

  if Rails.env.development?
    require 'heroku_san'

<span class="k">class</span> <span class="nc">MyStrategy</span> <span class="o">&lt;</span> <span class="no">HerokuSan</span><span class="o">::</span><span class="no">Deploy</span><span class="o">::</span><span class="no">Base</span>
  <span class="k">def</span> <span class="nf">deploy</span>
    <span class="k">super</span>
  <span class="k">end</span>
<span class="k">end</span>

<span class="no">HerokuSan</span><span class="p">.</span><span class="nf">project</span> <span class="o">=</span> <span class="no">HerokuSan</span><span class="o">::</span><span class="no">Project</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="no">Rails</span><span class="p">.</span><span class="nf">root</span><span class="p">.</span><span class="nf">join</span><span class="p">(</span><span class="s2">"config"</span><span class="p">,</span><span class="s2">"heroku.yml"</span><span class="p">),</span> <span class="ss">:deploy</span> <span class="o">=&gt;</span> <span class="no">MyStrategy</span><span class="p">)</span>

end

That should do it. Now we can deploy.

« back