Reputation: 3347
I previously was making some webapps using Spring MVC + PostgreSQL on my PC.
Wanted to try RoR, faced strange prob with DB connection, google isn't helping.
I created i new Rails web-application, made one model and tried to make a migration. (Last Rails gem, 5.0.0.beta3)
The problem is:
When i'm running db:migrate/create/drop Rails is trying to manipulate my existing DB's instead of creation new ones.
-i have a few PostgreSQL databases on my local PostgreSQL server, which i still want to keep active on it. Lets say 'XXXXXXX', 'YYYYYYYYY', 'ZZZZZZZZZ'
Once i run db:create i get the following log:
C:\Users\****\RubymineProjects\sample_articles>rails db:create
'XXXXXXX' already exists
DB migrate is executed successfully and also creating one additional database 'sample_articles_development', which is the name as i specify in my database.yml
. BUT the new tables appears to my existed database 'XXXXXXX'(which i didn't configure in any configs).
This is my database.yml
config:
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: sample_articles_development
username: rails
password: *******
host: localhost
port: 5432
test:
<<: *default
database: sample_articles_test
production:
<<: *default
database: sample_articles_production
username: sample_articles
password: <%= ENV['SAMPLE_ARTICLES_DATABASE_PASSWORD'] %>
Upvotes: 0
Views: 168
Reputation: 36880
You likely have a $DATABASE_URL
variable in your environment. That will override the value in database.yml.
unset DATABASE_URL
Upvotes: 1