Rails Heroku Database Population Rails Heroku Database Population sqlite sqlite

Rails Heroku Database Population


heroku commands have changed. now it should be:

heroku run rake db:pushheroku pg:reset DATABASEheroku 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 tapsheroku 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:


I setup the development db, and push it to Heroku.

rake db:resetrake db:seedheroku rake db:push

If you are using the default PostgreSQL, another option is

heroku pg:resetheroku rake db:seed

I use the following in the seed.rb file:

require 'pathname'RailsRoot = Pathname.new(RAILS_ROOT).expand_pathprint "Loading data..."fileData = File.read (RailsRoot + "db/data-file.csv")