Converting Rails from sqlite3 to PostgreSQL

Posted on

Your mod 3 and 4 projects were probably done using sqlite3. If you did your mod5 project in sqlite3, tsk tsk!

  • edit your Gemfile
  • comment out sqlite and add gem pg
  • Screen Shot 2018-06-13 at 11.51.49 AM
  • run “bundle install”
  • edit config/database.yml
  • Change your databases names, as below.
  • Screen Shot 2018-06-13 at 12.01.58 PM
  • run rake db:create
  • run rake db:migrate
  • run rake db:seed(if you have a seed file)
  • Now test your app, and you are now using Postgres!

How do I know that it worked?

  • Go to the little Postgres elephant, and click him
  • Press stop
  • Screen Shot 2018-06-13 at 12.11.01 PM
  • If your site does not work, then you migrated successfully. Refresh your browser if needed
  • Now start up Postgres so you can continue developing!
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s