Push an SQLite database to Heroku with taps? - ruby-on-rails

So I am trying to push a SQLite3 database to Heroku which I thought used to be possible, but reading here and here imply that it may not be (the below doesn't work).
heroku pg:push sqlite://db/development.sqlite3 HEROKU_POSTGRESQL_OLIVE_URL
! LOCAL_SOURCE_DATABASE is not a valid database name
Was this changed when Heroku switched the syntax to pg:push from db:push or was it never possible?
Given that it's not possible is the solution to migrate any data from SQLite3 to local postgres and then push to Heroku?

Heroku uses a read-only filesystem, which means that local file system based databases like SQLite3 aren't compatible with their infrastructure. And to my knowledge it has never been possible to push from a SQLite3 db directly to Postgres on Heroku.
You should migrate your data to a local Postgres database and push from there.

For what it's worth, it was possible to db:push from a local sqlite3 database to Heroku postgres, but there was a timestamp bug in any version of Ruby after 1.9.3.
Switching to postgres on local will end up being easier than messing with RVM and Gemfiles whenever you want to send data up to the server.

Related

Error when creating database record on rails console

I'm trying to create a new record through the rails console but I'm getting the following error:
PG::ConnectionBad: FATAL: database "my_database_development" does not exist
I've recently changed from Sqlite3 to PG to be able to deploy to Heroku. Is this what is giving the error?
Thanks a lot!
It looks like you have not yet run
rake db:create
This will "create" the databases on your PostgreSQL server. A step that you didn't have to do with SQLite, but Postgres requires it. As TK-421 said, make sure that your database.yml is configured for your OS and Postgres, not SQLite.
Here is a (possibly outdated) Railscast on the topic.
http://railscasts.com/episodes/342-migrating-to-postgresql
Is this running locally, or on Heroku? In config/database.yml, the local user you specify will need to have CREATEDB privileges (as a superuser, for example).
There's a little more configuration required in this case than for SQLite. Google will show you a bunch of tutorials specific to your OS.
If you see this problem in production on heroku, start the console like this:
rails console production
If you have that problem in development on your machine, check your config/database.yml. It is points to a local development database that does not exist.

Can I push my data directly to Heroku without using PG Backup Add-on?

I have the database schema ready on my Heroku App, but I want to push my data directly from my local database to Heroku.
Heroku dev center says it can be done using PG Backup Addon and pg_dump.
Any other way of doing it?
You should use heroku db:push
$> heroku pg:push --help
Usage: heroku pg:push <LOCAL_SOURCE_DATABASE> <REMOTE_TARGET_DATABASE>
Push from LOCAL_SOURCE_DATABASE to REMOTE_TARGET_DATABASE
REMOTE_TARGET_DATABASE must be empty.

Heroku: Dump Postgres database into local SQLite3 database for Rails project

Is there way to dump heroku postgres database and import the data into my local SQLite database?
I tried using https://github.com/ludicast/yaml_db and heroku db:pull with no success. I am developing on Windows 7.
Please read through
https://devcenter.heroku.com/articles/heroku-postgres-import-export
and follow those to export.
Though the above link can be used to export alone, it does not have solution for the entire process. So you can look on the similar question and its solution
Copy a heroku postgres db to a local sqlite db

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 Heroku Database Population

After deploying an app of Heroku I am having trouble getting the database populated with some of the data I need there. I ran heroku rake db:populate and it did create the initial admin user, but failed to put the rest of the data in.
I am populating the database with files from my local disk. I suspect the problem is caused because it sees nothing in the directory listed in the sample_data.rake file, as it in on my hdd and not the server. How can I get around this?
I figure that I have to either host all the files and change the directory to the servers directory, or find a way around this. I would guess there is an easy way to move the database from my computer to heroku? I'm obviously pretty new to this.
Thanks!
heroku commands have changed. now it should be:
heroku run rake db:push
heroku pg:reset DATABASE
heroku run rake db:seed
also data from local database can be uploaded to heroku by installing taps gem and pushing data from local PostgreSQL db.
gem install taps
heroku db:push
If you have a clean local database (i.e. just the good stuff, no silly testing data), then you could try heroku db:push:
db:push [<database_url>] # push a local database into the app's remote database
And please remember to develop on PostgreSQL if you're going to use the Heroku shared or dedicated databases, using the same database and version (version 8.3 for shared, 9.0 for dedicated) in both your development and production environments will save you much pain, suffering, and confusion.
References:
How can I import my existing data to Heroku?
Import: Push to Heroku
I setup the development db, and push it to Heroku.
rake db:reset
rake db:seed
heroku rake db:push
If you are using the default PostgreSQL, another option is heroku pg:reset
heroku rake db:seed
I use the following in the seed.rb file:
require 'pathname'
RailsRoot = Pathname.new(RAILS_ROOT).expand_path
print "Loading data..."
fileData = File.read (RailsRoot + "db/data-file.csv")

Resources