服务器需要postgres,即使我使用sqlserver

时间:2014-07-08 19:37:29

标签: ruby-on-rails sql-server postgresql deployment capistrano

我使用Capistrano进行部署:cap int deploy

然后,我将此作为我的database.yml文件

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000

sqlserver: &sqlserver
  adapter: sqlserver
  timeout: 5000
  database: Consumer
  username: '<%= ENV['DB_USERNAME'] %>'
  password: '<%= ENV['DB_PASSWORD'] %>'

development:
  <<: *default
  database: some_dev_db

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: some_test_db

int:
  <<: *sqlserver
  host: some_int_db

我的Gemfile如下:

source 'https://rubygems.org'

gem 'rails', '4.1.1'

gem 'rails-api'

gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter', git: 'https://github.com/rails-sqlserver/activerecord-sqlserver-adapter'

gem 'unicorn'

gem 'active_model_serializers'

gem 'figaro'

gem 'faker'

gem 'spring', group: :development

group :development, :test do
  gem 'pry'
  gem 'pry-nav'
  gem 'pg'
end

group :deployment do
  gem 'capistrano'
  gem 'hipchat'
end

我在服务器上运行bundle install之后尝试做了一些事情,但是我收到了一个需要gem pg 0.17.1的错误。然后,我做了bundle install --without development test,因为我不需要服务器上的PG。

即使我执行bundle exec RAILS_ENV=INT rake db:migrate之类的操作并尝试打开int环境控制台,我仍然可以得到我的服务器需要pg的事实。为什么会这样?

1 个答案:

答案 0 :(得分:0)

尝试更改

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000

到这个

default: &default
  adapter: sqlserver
  pool: 5
  timeout: 5000

为我工作。