Fetch database from production to development - ruby-on-rails

I love very much heroku database pulling:
heroku db:pull
It is very helpful when you are fixing bugs caused by data at production.
Is it any gems that can easily pull database from production without heroku?

Check out the Tap gem: https://github.com/ricardochimal/taps. This should do what you want.

Related

Migrate data from Develpment DB to Production DB with Rails on Heroku

I'm kind newbie on Rails. I developed an small CMS running on Heroku and using Postgres.
I manually inserted a few data on my Development db. And I'd like to fill the Production DB with such data.
Both DB are equals. Same structure, fields etc.
I tried through gem install yaml_db
--> gem 'yaml_db' ->rake db:data:dump → rake db:data:load
But I got: “rake aborted!
Don't know how to build task 'db:data:load'
”
Is that the proper approach? What am I doing wrong?
Thanks
You can import your local database to heroku database easily using heroku pgbackups by follow the instructions here.
Please check here in Heroku Docs
heroku db:push

Heroku incorrectly reports a model validation error?

I'm a newbie developing a rails app. I pushed the master to Heroku and ran "git heroku run rake db:migrate" without problems.
The app runs great locally, but on Heroku a "duration" field in one of my tables erroneously reports an error indicating that it "can not be blank" even though I pass it a valid value per the model's validation. This behavior only occurs on Heroku. Locally, the "presence" validation behaves as expected. Heroku does not indicate any problen with my database schema, but it appears something may be wrong in the database. That's my hunch, but I don't know.
To troubleshoot: I reset the Heroku database by running "heroku pg:reset DATABASE" and then ran "heruko run rake db:migrate". Those commands did not solve the problem.
I don't know how to troubleshoot further. Any thoughts, suggestions or ideas? I'm running SQLite3 in my development & testing environments with pg on Heroku. I haven't made any unusual SQLite migrations. I do plan to get rid of SQLite3 and go with pg entirely, but I need to solve this problem first. Thanks in advance for any help!

Push an SQLite database to Heroku with taps?

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.

How to move Rails app + pgsql database from localhost to my server?

I am assuming I have to use capistrano but still unsure. I want to move my rails app and the databases (since they already have lot of data now) to the server, how can I do it ?
Thanks
to move your database schema... rake db:schema:dump will dump it to schema.rb and rake db:schema:load will load them.
You can use capistrano to build a deployment system. I personally use git to promote my apps to production. I use Engine Yard (www.engineyard.com) and Heroku (www.heroku.com) for hosting. Deployment is super-simple with both.
As far as the database goes it depends on your server implementation. Most likely you'll need to backup and restore the database into production.

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