Converting a ruby on rails app from sqlite to postgresql
Asked Answered
R

3

5

I am going to use thinking sphinx for my application and it requires a conversion to postgresql. I have downloaded both sphinx and postgresql using homebrew, but I am unsure how to convert the rest of the application. I do not care about saving my data, as I only have about 5 records in my database. If there is a step by step guide, or a resource that could guide me I would appreciate it.

Ratable answered 9/10, 2011 at 22:5 Comment(0)
R
1

I used the following video from Peter Cooper to figure out what I was doing wrong. If anyone needs to set up Postgresql in the future reference this: http://www.youtube.com/watch?v=pf5jPUJAeU4

Ratable answered 17/10, 2011 at 20:3 Comment(0)
S
5

It's a very simple process if you have stuck to using activerecord and not used any custom SQL.

All you'll need to do is change your gemfile to include gem 'pg' and change the database.yml file to have something like the following:

  development:
    adapter: postgresql
    database: example_development
    username: postgres
    password: secret
    host: localhost
    encoding: UTF8

If you have used custom SQL, you'll just need to convert it to PostgreSQL, which shouldn't be too tricky as it's very similar.

Standpoint answered 9/10, 2011 at 22:11 Comment(4)
What about the database line, what do I write for that?Ratable
drop your existing database and recreate it (using rake db commands) after making changes as suggested by Simon.Forequarter
I keep getting password errors, which doesn't make sense to me as I am providing the correct password to sign in to postgresql. I created a new app using postgresql on my system and it ran perfectly. I looked at the database.yml file and it was slightly different than the one provided, copied that format and it still didnt work. Any suggestions?Ratable
I've updated the example above to include the exact things you'll need to provide. Are you sure you can access login to psql with the exact same username and password settings as the yml file has?Standpoint
R
1

I used the following video from Peter Cooper to figure out what I was doing wrong. If anyone needs to set up Postgresql in the future reference this: http://www.youtube.com/watch?v=pf5jPUJAeU4

Ratable answered 17/10, 2011 at 20:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.