Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 433
Jake Stevens Avatar asked Oct 16 '25 08:10

Jake Stevens


1 Answers

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.

like image 110
Paul Annesley Avatar answered Oct 18 '25 03:10

Paul Annesley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!