Steps for postgres update from 10 to 11 on heroku - ruby-on-rails

PostgreSQL 10.22 reaches End of Life on 2022-Nov-10. Due to security and operational concerns, Heroku cannot run unsupported software as a service. Therefore, the following database will need to be updated before 2022-Nov-10
So, this is not really an issue but I wanted to have a clearer picture.
My current heroku postgres version is 10 which will deprecate and i would like to move to 11. The rails version is 5.2 and ruby is 2.6.7
I was suggested to use the pg_upgrade tool because my checksums are enabled as per the heroku documentation. It says to provision a follower, turn maintenance mode on and then hit pg upgrade. I am not sure how it will automatically select the next version or where to specify it?
The second option is from from this Stackoverflow verified article
This works locally for me, but am not sure if I can use this on live server. I want to make sure there is no loss of data.
Can some please provide me the steps or the right article to get my postgres upgraded from 10 to 11 on Heroku.

Turns out I was trying to add the version while creating an add on, where this should be done while using the pg_upgrade tool.
Shared below are the steps i had to follow:
heroku addons:create heroku-postgresql:standard-0 --follow HEROKU_POSTGRESQL_PUCE_URL --app -app_name-production
heroku maintenance:on --app app_name-production
heroku pg:upgrade HEROKU_POSTGRESQL_CYAN --version 11 --app app_name-production
heroku pg:wait --app app_name-production
heroku pg:promote HEROKU_POSTGRESQL_CYAN --app app_name-production
heroku maintenance:off --app app_name-production

Related

Unable to deploy rails test app to Heroku

I'm working through the odin project's web development course and I'm getting tripped up on the last part of the installations project where you are tasked with deploying a rails app to Heroku. I've been working on this for about a week but I refuse to give up but I realize that I need some help.
Here's the link to the tutorial I'm trying to work through (on a mac):
http://installfest.railsbridge.org/installfest/deploy_a_rails_app
I have a Heroku account set up, and am running Ruby 2.3.0 and rails 4.2.5.1. Rubygems are at 2.6.1 (but I tried them at 2.5.1 too).
Everything works fine but when I get to heroku run rake db:migrate I always get the time out error:
[~/railsbridge/test_app] ruby-2.3.0 $ git push heroku master
Everything up-to-date
[~/railsbridge/test_app] ruby-2.3.0 $ heroku run rake db:migrate
Running rake db:migrate on powerful-journey-35824... up, run.9421
▸ ETIMEDOUT: connect ETIMEDOUT 50.19.103.36:5000
I saw another post suggesting that the problem is a result of the connection I'm using blocking port 5000 (I'm at a library). I checked port 5000 on canyouseeme.org as well but it also timed out.
I then tried deploying the app detached using heroku run:detached rake db:migrate and it seems to work until I open heroku again and it shows that the page I'm looking for doesn't exist.
Basically what I'm asking is, does anyone have any idea why this test app isn't getting pushed from my terminal to the heroku deployment page?
I'm a python/django guy, but taking a guess the "everything up to date" message is likely because you have not commited your changes to git. Try:
git commit -a
git push heroku master
Now run your rake command.

how can I access my postgresql database on heroku and offline?

I am learning ruby on rails and heroku.
I have some questions.
Could somebody help me?
After running heroku create, the terminal is somehow connected to the repository/project in heroku. After that the developer can see logs, access database, ect. But, how can I access via terminal my completed project,which is online already, in heroku without creating the same apps and upload it again to heroku?
How can access my pg database in heroku or offline?
I saw this and try to run heroku pg:psql. it gives me hidden-atoll-4790::DATABASE=> help I try \? to see pg command but I cannot use it.
I saw this link to see pg db offline. But why cannot I access /var/lib/postgresql/9.3/main directory ? it is said that I don't have permission eventhough my account is administrator account.
1.Run heroku run rails console
Run
$ heroku apps # to see all apps created by your account
$ heroku open # to open you current project in browser (run it form root of your project)
$ heroku pg:psql DATABASE_URL # to gain access to heroku postgresql terminal, here you can run SQL queries
Refer to
CLI and Heroku PG for more info

Migrate PostgreSQL database back to local machine

I've recently re-installed Mac OS X on my Macbook, and am just getting my development environment and projects back up and running again. For one of my Ruby on Rails apps (which is running on Heroku) I need to grab the (PostgreSQL) database from Heroku and migrate it back to my development environment. How would I go about doing this?
I fixed this by first creating my database (psql in Terminal) and then using the CREATE DATABASE db_name command. Then I used heroku pg:backups capture to capture a backup/shot of the database. I downloaded this using heroku pg:backups public-url b001 and then pg_restore --dbname=db_name --verbose /path/to/download.
Hope that hopes anyone!

migrate mongodb database to heroku

I have now my rails 3.2.1 app running on Heroku.
I've tried to upload the database to mongohq via the heroku mongo:push command, after installing the heroku mongo plugin.
https://github.com/pedro/heroku-mongo-sync
I get the message asking me to confirm if I want to push, but once the push is done, there is nothing my db.
I'm not sure if it is a problem with heroku or if i'm missing a step.
Could it be that i need to put my app in production mode and migrate the database to production?
I'm not sure how to do that either.
Cheers
does your local heroku connection conform to the plugins assumptions [in the readme's config section]? if not you'll have to set it via:
export MONGO_URL = mongodb://user:pass#localhost:1234/db
i'll also note, that even after doing this i had to uninstall the heroku plugin and reinstall it from this fork: http://github.com/fjg/heroku-mongo-sync.git
heroku plugins:install http://github.com/fjg/heroku-mongo-sync.git
Check out the MongoSync Ruby Gem
It's a gem I wrote for that very purpose when I had to constantly copy my Local MongoDB database to and from my Production DB for a Project (I know it's stupid). It's extremely easy to use. Once you've entered your DB details in the mongo_sync.yml file, you can push and pull DBs using these rake tasks:
$ rake mongo_sync:push # Push DB to Remote
$ rake mongo_sync:pull # Pull DB to Local
Note: It's also available as shell script for non-ruby apps: mongo-sync

Rails app using Mysql how to deploy with heroku?

How to deploy a Rails app using Mysql on heroku?
I find out that my app did not need Amazon RDS (Too expensive for a small app).
Here is my answer how to use Amazon RDS
Heroku help deploying Rails app that uses Mysql database
Include mysql2 gem in your gemfile:
gem 'mysql2'
Now, your choice can be: https://addons.heroku.com/cleardb add-ons. You can get upto 5mb free storage but you need to fill your credit card information for accessing it.
Steps for using clearDB add-ons are:
# add cleardb add-ons to your app
$ heroku addons:add cleardb:ignite
-----> Adding cleardb to sharp-mountain-4005... done, v18 (free)
# retrieve your database URL:
$ heroku config | grep CLEARDB_DATABASE_URL
CLEARDB_DATABASE_URL => mysql://adffdadf2341:adf4234#us-cdbr-east.cleardb.com/heroku_db?reconnect=true
# copy CLEARDB_DATABASE_URL config variable and set it to your DATABASE_URL config variable
$ heroku config:set DATABASE_URL='mysql://adffdadf2341:adf4234#us-cdbr-east.cleardb.com/heroku_db?reconnect=true'
Adding config vars:
DATABASE_URL => mysql2://adffd...b?reconnect=true
Restarting app... done, v61.
# NOTE: since we are using ```mysql2``` in our gemfile so replace mysql:// scheme in the CLEARDB_DATABASE_URL to mysql2://
$ heroku config:set DATABASE_URL='mysql2://adffdadf2341:adf4234#us-cdbr-east.cleardb.com/heroku_db?reconnect=true'
$ heroku config:set CLEARDB_DATABASE_URL='mysql2://adffdadf2341:adf4234#us-cdbr-east.cleardb.com/heroku_db?reconnect=true'
Please follow: https://devcenter.heroku.com/articles/cleardb for more information
Hope that can help you.
If you do a heroku db:push from your MySql data, it'll automatically get pushed into the heorku PostgreSQL database structure.
You can then do db:pulls and pull back into mysql. Taps provides this database magic.
It's really great -- I'd try it out first before trying to get RDS working.

Resources