After deploying to Heroku, I want the migrations to run after deployment. Tried following configuration in circle.yml -
deployment:
staging:
branch: <branch_name>
heroku:
appname: <appname
commands:
- heroku run rake db:migrate --app alldaydr:
timeout: 400
- bundle exec rake swagger:docs
commands:
- git push git#heroku.com:<appname> $CIRCLE_SHA1:master
- heroku run rake db:migrate --app <appname>
It deploys successfully but doesn't run migrations. Any help/idea?
Here is my configuration that works below. I have just one commands instruction and run rake migration just after push to Heroku. You can also get a hint of what's happening from the deploy logs on CircleCI.
deployment:
production:
branch: <branch-name>
commands:
- "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
- git push git#heroku.com:<appname> $CIRCLE_SHA1:refs/heads/master
- heroku run rake db:migrate --app <appname>:
timeout: 400 # if your deploys take a long time
- heroku run rake swagger:docs --app <appname>
Refer to CircleCI's documentation for more
Related
I have demo ROR app in Heroku and I would like to reset PG DB everyday via Heroku Scheduler. I have some commands, but I don't know how I can use they in Heroku Scheduler. I just paste this, but it don't work for me.
commands:
heroku restart && heroku pg:reset DATABASE_URL --confirm APP_NAME_ON_HEROKU && heroku run rake db:migrate && heroku run rake db:seed
Could you please tell me, how I should to use this commands?
for me worked it:
rake db:schema:load DISABLE_DATABASE_ENVIRONMENT_CHECK=1 && rake db:seed
UPD:
the commands(heroku run rake db:migrate) that I performed early, working only from the Heroku CLI. For Heroku Scheduler we must use these commands without a keywords heroku run. rake db:reset don't work, disabled on the side Heroku. Also I couldn't use heroku pg:reset DATABASE_URL --confirm APP_NAME_ON_HEROKU.
useful links:
How to reset PG Database on Heroku?
Running Rake Commands
Here is the official documentation link
You can use the following command below.
heroku run rake db:schema:load DISABLE_DATABASE_ENVIRONMENT_CHECK=1 db:seed
I have a ruby on rails app, leveraging Postgres running in heroku. I have a staging environment and a production environment in heroku. I want to run the heroku run rake db:migrate on the production environment however I can find the command to do so, any help would be greatly appreciated
I think you can just set the remote to get it to pick the right environment:
heroku run rake db:migrate --remote production
When I ran heroku run rake db:migrate --remote it gave me three choices (heroku, staging & test) I ran the command: heroku run rake db:migrate --remote heroku and it worked!! (didn't understand that heroku was calling my production environment "heroku" and not production) thanks again for all your help
I am trying to set up a workflow that pushes to heroku after I push to my main branch on my github repo. I have done this before with a previous project. I copied over the circle.yml file and changed the name of the old app to the new app, but circle ci gets stuck on the line that says " - git push git#heroku.com:my_app_name.git $CIRCLE_SHA1:refs/heads/master"
circle.yml
machine:
ruby:
version: 2.1.2
deployment:
production:
branch: master
commands:
- heroku maintenance:on --app my_app_name
- heroku pg:backups capture --app my_app_name
- git push git#heroku.com:my_app_name.git $CIRCLE_SHA1:refs/heads/master
- heroku run rake db:migrate --app my_app_name
- heroku maintenance:off --app my_app_name
staging:
branch: staging
commands:
- heroku maintenance:on --app my_app_name
- git push git#heroku.com:my_app_name.git $CIRCLE_SHA1:refs/heads/master
- heroku run rake db:migrate --app my_app_name
- heroku maintenance:off --app my_app_name
I'm getting a remote rejected error at the line
- git push git#heroku.com:my_app_name.git $CIRCLE_SHA1:refs/heads/master
I think I'm getting this error because "git#heroku.com:my_app_name.git" may not be correct. How do I find what to put here?
my_app_name should be replaced by whatever app name is being used on Heroku.
I am developing my first Rails app, and I have made some database entries that are showing up in the development environment, but not in the production environment (Heroku). I have run
git add
git commit
git push origin master
git push heroku master
rake db:migrate
in the terminal.
$ heroku create
$ git push heroku master
After running these commands, to get the application’s database to work, you’ll also have to migrate the production database:
$ heroku run rake db:migrate
$ heroku open
if this doesn't work please show your logs.
you just need to run
heroku run rake db:migrate
I am trying to deploy a rails project into heroku using travis. Build is successful and tests are also passing. Deployment is also successful. but when I test the heroku app, I find that image files in my app/assets/images directory are not getting displayed in the deployed application.
Here is my .travis.yml file.
language: ruby
rvm:
- 2.2.3
gemfile:
- gemfiles/Gemfile.rails-4.2.5
env:
- DB=sqlite
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- RAILS_ENV=test bundle exec rspec -f d
install:
- bundle install
deploy:
provider: heroku
skip_cleanup: true
app: <my app name>
api_key:
secure: <proper key>
on:
gemfile: gemfiles/Gemfile.rails-4.2.5
strategy: git
run:
- "rake db:migrate"
Can somebody help me understand why image files are missing. I can see them in my github application folder. but they are not getting deployed properly by travis to heroku.
thanks
I see you are usign Rails 4, are you sure to be setting serve_static_assets = true in production.rb?
Refer to Rails 4 images not loading on heroku.
Also, make sure to precompile your assets as you deploy from Travis CI. So add under deploy: run:
deploy:
...
run:
- "rake db:migrate"
- "RAILS_ENV=production bundle exec rake assets:precompile"