ga-wdi-exercises / project2

[project]
1 stars 30 forks source link

Switching from sqlite3 to postgresql after the fact #845

Closed justwes2 closed 7 years ago

justwes2 commented 7 years ago

When I generated my rails app, I didn't specify postgres so it used the default. I switched to postgres when I put it up to heroku, and the deployed app works fine. The problem is that the gemfile is updated and so the localhost can't launch. I've tried updating the database.yml file, but its not letting me run db:create anymore since it can't find the sqlite gem.

amaseda commented 7 years ago

What does your database.yml file look like now?

justwes2 commented 7 years ago

This is what it looks like out of the box. I tried replacing sqlite3 with postgresql, per the stack overflow post, but my terminal was still looking for an sqlite3 gem.

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3
justwes2 commented 7 years ago

I went through the whole file and found a few other instances to switch. Now I can't create a database using db:create

amaseda commented 7 years ago

The file should look something like this (comments removed). Make sure to replace "scribble" with your Rails app name...

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: scribble_development

test:
  <<: *default
  database: scribble_test

production:
  <<: *default
  database: scribble_production

If you do that and make sure to include the "pg" gem in your Gemfile, you should be able to run the usual rails commands. Let me know if that does/doesn't work.

justwes2 commented 7 years ago

I made those changes and it seems to be working. Too bad I had to drop my database to get there.

justwes2 commented 7 years ago

Part of my fix was to remove my local version and clone it from heroku. The problem I am having is trying to reset the remote origin. I'm using git remote set-url origin https://github.com/justwes2/wellnyss and getting fatal: No such remote 'origin' but the page exists. How do I get the github repo updated?

amaseda commented 7 years ago

What is the current output of $ git remote -v?

justwes2 commented 7 years ago

  Wed Mar 01 17:03:13 ~/wdi/projects/wellnyss (master)
$ git remote -v
heroku  https://git.heroku.com/wellnyss.git (fetch)
heroku  https://git.heroku.com/wellnyss.git (push) ```
amaseda commented 7 years ago

So it only looks like you have a remote for heroku. If you're going to use origin you need to add that remote, not set-url

justwes2 commented 7 years ago

got it. Thanks!