Heroku for some reason doesn't support sqlite3 in their deployments. So, it is must to migrate your db from default sqlite3 to mysql or postgresql.
In order to do that you need to first add pg gem to your Gemfile file:
Then install the gem with bundle install.
change database.yml file to use postgresql
development: adapter: postgresql database: my_app_development pool: 5 timeout: 5000 test: adapter: postgresql database: my_app_test pool: 5 timeout: 5000 production: adapter: postgresql database: my_app_production pool: 5 timeout: 5000
- Start postgres as service on your local machine:
brew services start postgresql
Now create the database by running
this creates local db
Create the tables using the famous
If you have seed data like I do, then do rake db:seed
Sometimes the postgresql that's on your machine might be old one and so it becomes problematic to run postgresql service and create local database that your development env is trying to connect to. If that's the case then you need to update your postgres version
- Update postgresql
- Restart postgres service
brew services restart postgresql
- Go to your apps root & create the database in postgresql
rails db:createThis will create a new
my_app_developmentdb in your local postgres instance
- Now the usual steps follow like migrating db & seeding data if you have any.