Unable to upgrade heroku database - ruby-on-rails

I've just upgraded my heroku database. I'm now trying to copy the data from my old database to my new database, however I keep getting this error. Could it be that I'm unable to copy it because write access is revoked?

Why not just import and export a backup using PG Backups, your issue here is that your databases are in different apps(environments), so from the console using --app earthedhub will just let you use the DATABASE_URL.
use a PG Backups take a look to this post

Related

I would like to create new postgres sql DB for Heroku

I have deployed an application in Heroku. It is Rails applications. The DB is postgres. So this is the app in heroku. Now I want to create new app which will be a clone of the previous app. But it will have separate DB. How should I get going? I would also like to know about configuring the DB from heroku. I am not so techy so please go easy on me.
Thanks!
But it will have separate DB
So, just create a new heroku app, add PG add-on to it, and that's it. No more steps. It will have a separate database. I think you don't even have to add PG add-on, it probably is added by default.
If you wanted two apps use the same DB, then you'd have to do extra steps.
You can use Heroku Fork to clone your application. This will copy the app, environment variables and any postgres databases (and their data if you want it) to a separate Heroku application.
heroku fork --from old-app-name --to new-app-name

Rails import database on heroku

I am trying to import a database from my computer to heroku but it keep on saying unknown command for that.Even I am confuse about it which command to use .I have a postgre sql database.I want to know how to import a database
push from SOURCE_DATABASE to REMOTE_TARGET_DATABASE
REMOTE_TARGET_DATABASE must be empty.
SOURCE_DATABASE must be either the name of a database
existing on your localhost or the fully qualified URL of
a remote databas
So what will be the remote_target_database ???
and do i need to specify my full path to source database ?
Try the following.
heroku pg:push your_app_name_development DATABASE_URL
PG Backups can be used as a convenient tool to import database dumps from other sources into your Heroku Postgres database.
https://devcenter.heroku.com/articles/heroku-postgres-import-export
How to import a Heroku PG dump into local machine

synching two databases in heroku rails app

I have crm rails application deployed in heroku so my database is postgresql. I have an iphone app which is using mysql database. Now what i need to do is to synch my iphone database with my heroku database.
Can anyone please help me on this is it possible to sync two different databases in heroku
Thanks in Advance
The way we did this was to do it manually
Yep, it's a real pain, but at least you know it's done correctly
--
Process
For migrating from Postgres to MYSQL is as follows:
"Backup" the database using pg_backups
Download the backup locally
In MYSQL (we used PHPMyAdmin), create a series of SQL calls to insert the respective data into the correct tables
Migrating from MYSQL to Postgres is, as much as I can determine, a similar process:
Download the SQL dumps of your MYSQL DB (I only know how to do this in PHPMyAdmin)
Configure those files to be "PG" ready
Send the SQL to your Heroku postgres db's
--
Notes
For specifics, I only have the following:
If you dump from Heroku, you'll not get a traditional SQL file; you'll receive a .dump file. To change this, you'll need to use pg_restore in the following way:
$ cd c:/your/postgres/install/pg_restore/location
$ pg_restore path_to_your_dump.dump > path_to_your_sql.sql
This will give you the ability to "read" the file, uploading to your db & importing as you wish. That's when the fun begins :)
Importing MYSQL
The way to import MYSQL into a PG db will have to be done manually
Although we've never done this directly (we only migrated from PG), there are several things you can do. Firstly, you can use the PG2MYSQL converter to give you an idea as to the syntax differences between MYSQL & PG
Then I would perform a "dump" from MYSQL in SQL format. This will give me the data required for PG. This will allow me to insert into my PG database (you might have to do this locally to give you the ability to determine the syntax), from which you can then patch in the MYSQL data
I understand it's not the most elaborate explanation - I hope it gives you some ideas

How do you access your heroku database (specifically postgres)?

When I am developing locally, I'll just run a
rails c
and I can fire of queries at the console.
However, how can I query and access my postgres database that is up on heroku?
You can run heroku run rails c --app <appname>. I will also add, if you want to view your database, you can make use of PG Commander https://eggerapps.at/pgcommander/ which actually automatically parses all the credentials out for you.
If you want to do this, run heroku config --app <appname> and then copy the DATABASE_URL. After you've done this, create a new favourite in your PG Commander and you'll see that it has already automatically filled in all the credentials based on what was in your clipboard.

How do I check the records of my heroku database?

I've just deployed my application to heroku and pointed my custom domain to the heroku servers. How can I check the records in my heroku database?
You can use heroku run rails console and look at your records with Model.all or any other method.
If you want to backup the database look at heroku PG backups, you then can import your database on your local machine and look at it there. Depending on your db adapter you could use sqlite browser for sqlite3 or phpmyadmin for MySQL.
I found a similar question like this and here is what #Chowlett says:
"You could run heroku pg:psql to fire up a Postgres console, then issue \d to see all tables, and \d tablename to see details for a particular table."
You can also type select * from tablename; to view the table contents.
How to view current database schema for Heroku app in Terminal?
heroku db:pull to pull your production DB locally to take a peek in it.
I'll give the method for connecting via a GUI tool
Run the following command to get the database credentials from Heroku:
heroku pg:credentials DATABASE_URL
Then you can use a GUI tool like PG Commander or PGAdmin to connect to the db
Heroku now has an add-on named PostgreSQL Studio (currently free & in beta) that would let you access your database from within the browser, without having to use CLI, much like PHP MyAdmin.
To attach this add-on to your application,
heroku addons:create pgstudio
Then go to the list of add-ons on Heroku, select PostgreSQL Studio, authorize it, select the database to connect with from the dropdown list of all databases and it will take you to the web-based interface to handle your selected database.
You may refer to this official article on Heroku:
https://devcenter.heroku.com/articles/pgstudio
The easy answer is:
heroku pg:info
You can also download a client side Postgres, like Postico, and using the information provided in that URL to enter password and database name etc, then you can create locally, just like phpMyAdmin.
I use the admin_data gem, works well in Heroku.
You can use heroku dataclips that allows to run queries online. Here you can find documentation https://devcenter.heroku.com/articles/dataclips.
Connect to the database using Sequel Pro. You can find your ClearDB url using heroku config command. The structure for connecting is as follows:
CLEARDB_DATABASE_URL => mysql://[username]:[password]#[host]/[database name]?reconnect=true

Resources