Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting a ruby on rails app from sqlite to postgresql

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.

like image 945
tomciopp Avatar asked Oct 09 '11 22:10

tomciopp


People also ask

Is PostgreSQL better than SQLite?

SQLite doesn't perform well when it comes to user management. It also lacks the ability to handle simultaneous access by multiple users. PostgreSQL performs very well in managing users. It has well-defined permission levels for users that determine what operations they can perform in the database.

Is SQLite faster than PostgreSQL?

SQLite 2.7. 6 is significantly faster (sometimes as much as 10 or 20 times faster) than the default PostgreSQL 7.1. 3 installation on RedHat 7.2 for most common operations.


3 Answers

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.

like image 138
sren Avatar answered Oct 05 '22 00:10

sren


http://devcenter.heroku.com/articles/database#common_issues_migrating_to_postgresql

like image 45
Chris Avatar answered Oct 05 '22 00:10

Chris


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

like image 30
tomciopp Avatar answered Oct 05 '22 02:10

tomciopp