Jake Stevens
Jake Stevens

Reputation: 157

How to switch my Rails app to postgresql from Sqlite3?

So I started working on a Rails app recently and we decided (well not me, the person working on it with me) that we should switch from Sqlite3 to Postgresql. I've installed Postgresql on our server properly, created the databases for dev, prod, and test, and updated my Gemfile and database.yml files with the code for Postgres. The thing I'm unsure of now, is how to switch out all the files in the db directory with the Postgres databases. Do I just delete the contents of the db directory in my app and run rake db:create?

Upvotes: 4

Views: 1210

Answers (1)

Paul Annesley
Paul Annesley

Reputation: 3397

You'll want to edit config/database.yml to use postgresql instead of sqlite.

The migrations in db/migrate/*.rb are hopefully cross-database compatible, and wont need to be changed.

Running rake db:create db:migrate with the new database.yml should create the PostgreSQL database and you'll be up and running.

In reality, you'll probably run into various problems, but this will be a starting point.

Upvotes: 4

Related Questions