Reputation: 45
I was recently added to a Rails application via Heroku. I'm able to clone the app to my local machine using:
heroku git:clone -a appname
However, I have issues running local tests and other tasks related to not having a local database. The production environment uses Postgres and the development environment uses sqlite3. What's the best way to get a local database setup?
Upvotes: 0
Views: 297
Reputation: 139
As you have successfully clone rails project from Heroku and your production database is PostgreSQL which is different from your local database SQLite you should update some files from your local project
1. remove or comment "gem pg" and add gem 'sqlite3' and run bundle install
2. Make changes in your database.yml file
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
3 run rake db:create
4 run rake db:migrate
5 if you have data in seed file run rake db:seed
Upvotes: 0
Reputation: 359
You will need to setup the databases required for development. This can be done using the built in rake db
tasks:
rake db:create
rake db:migrate
This should see your local database created and migrated up to the latest migration.
Upvotes: 0
Reputation: 4561
Simply pull the production database from Heroku. Run the following once you have heroku_toolbelt and you have access to the app on Heroku:
heroku pg:pull DATABASE_URL app_development --app app_name_on_heroku_here
This will create a new database locally named "app_development" so rename it to your app. See config/database.yml
for your development database name.
Upvotes: 0