Fresh rails app defaulting to Postgres instead of SQLite3
The problem is that when you start the server it is looking for environment variable DATABASE_URL which is probably set to postgres and this takes precedence over the database.yml file. You can delete the environment variable, and it should work, or you can reset it to SQLite.
How do I change rails' default database from sqlite3 to postgres, across all new projects?
Create a .railsrc
file in your HOME directory and put your db override there
# ~/.railsrc
--database=postgresql
You can add all other overrides that you might want to use, like --skip-test-unit
or the like.
This file will be applied each time you run a rails new
command.
Change from SQLite to PostgreSQL in a fresh Rails project
You can change your database.yml to this instead of using the out of the box sqlite one:
development:
adapter: postgresql
encoding: utf8
database: project_development
pool: 5
username:
password:
test: &TEST
adapter: postgresql
encoding: utf8
database: project_test
pool: 5
username:
password:
production:
adapter: postgresql
encoding: utf8
database: project_production
pool: 5
username:
password:
cucumber:
<<: *TEST
How to switch my Rails app to postgresql from Sqlite3?
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.
Related Topics
Ruby: Why Are All Coordinates Getting Updated in an Array of Arrays
How to Reset Boolean to "Default: False" at End of Day
How to Cancel Evaluating a Required Ruby File? (A.K.A. Top-Level Return)
Use [].Replace to Make a Copy of an Array
Shading Mask Algorithm for Radiation Calculations
How to Iterate Through This JSON Document Using Ruby
Run Ruby Script That Is Stored on Internet
Generating Devise Controllers - Rails Devise
Ruby 2.1 with Erubis Template Engine
Adding Fields to Devise Sign Up Using Rails 4
Bundler How to Uninstall Conflicting Dependency
Share Session Between Two Rails4 Applications
Set Site/User Fields in Activeresource
Ruby Getting Deeply Nested JSON API Data