3

I have more than 10 different Ruby on Rails apps where I have to deploy the same code. I have connected the git repo to my Heroku apps, so whenever I push new changes it deploys on all of them.

The issue is with the database migration step. I want to run migrations automatically after each deployment. None of custom build pack is working. Can someone please help me? I am using rails 4 and spree.

So far, I have tried:

  1. https://github.com/heroku/heroku-buildpack-ruby.git
  2. https://github.com/gunpowderlabs/buildpack-ruby-db-migrate.git

This solution is not working.

Is there any other solution to run Rails migrations on Heroku automatically?

lucasarruda
  • 1,462
  • 1
  • 25
  • 45
Shoaib
  • 1,114
  • 1
  • 7
  • 17
  • the log says the it can't find file `iconv`, have you checked that? – xiaoboa Mar 22 '16 at 07:47
  • when i remove buidpack everything start working fine.my deployment done successfully. question is i want to run migration auto? – Shoaib Mar 22 '16 at 08:05

3 Answers3

11

No need to use gems or write scripts. Heroku have a 'release' phase features (https://devcenter.heroku.com/articles/release-phase).

Thank to this, you just have to add to your Procfile some code to automatically run rake db:migrate to all your push :

Procfile (root app)

release: rake db:migrate
Gregdebrick
  • 533
  • 6
  • 14
1

You can use Travis-ci. Pretty simple to setup and provides the desired functionality

SomeSchmo
  • 665
  • 3
  • 18
-1

Add gem 'iconv', '~> 1.0.3' to your gemfile and then try it will work as worked for me!

I take this as a duplicate of this answer

If you are looking for alternative then you can write a deploy script in .sh file and run it everytime like bash script.

Community
  • 1
  • 1
Muhammad Ali
  • 2,173
  • 15
  • 20
  • Originally i want to run migration auto on heroku after deployment – Shoaib Mar 22 '16 at 08:32
  • yes iconv is like a dependency, have you tried the solution ? it should work fine. – Muhammad Ali Mar 22 '16 at 09:22
  • How does that relates to migrations? If somehow that gem runs migrations, it's a side effect no one should expect or know of. So this should never be the solution to the problem. @Gregdebrick solution works properly and is the correct answer – lucasarruda Feb 13 '19 at 19:11