使用2个postgres服务器

时间:2015-04-22 11:55:54

标签: ruby-on-rails migration postgresql-9.2 postgresql-9.3

我在ubuntu版本上安装了2台postgres服务器:9.3.6;版本:9.2.6。如何定义要在rails中使用的pg_dump版本。

  $ rake db:migrate
  pg_dump: server version: 9.3.6; pg_dump version: 9.2.6
  pg_dump: aborting because of server version mismatch
  rake aborted!
  Error dumping database
  /home/pair/.rvm/gems/ruby-2.0.0-p481@uptick/gems/activerecord-4.1.0/lib/active_record/tasks/postgresql_database_tasks.rb:55:in `struct>
  /home/pair/.rvm/gems/ruby-2.0.0-p481@uptick/gems/activerecord-4.1.0/lib/active_record/tasks/database_tasks.rb:150:in `structure_dump'
  /home/pair/.rvm/gems/ruby-2.0.0-p481@uptick/gems/activerecord-4.1.0/lib/active_record/railties/databases.rake:269:in `block (3 levels)>
  /home/pair/.rvm/gems/ruby-2.0.0-p481@uptick/gems/activerecord-4.1.0/lib/active_record/railties/databases.rake:43:in `block (2 levels) >
  /home/pair/.rvm/gems/ruby-2.0.0-p481@uptick/gems/activerecord-4.1.0/lib/active_record/railties/databases.rake:37:in `block (2 levels) >
  /home/pair/.rvm/gems/ruby-2.0.0-p481@uptick/bin/ruby_executable_hooks:15:in `eval'
  /home/pair/.rvm/gems/ruby-2.0.0-p481@uptick/bin/ruby_executable_hooks:15:in `<main>'
  Tasks: TOP => db:structure:dump
  (See full trace by running task with --trace)

数据库配置:

development:
  adapter: postgresql
  encoding: unicode
  database: tradeapp_development
  pool: 5
  username: postgres9_3
  password: postgres9_3
  host: localhost
  port: 5434

1 个答案:

答案 0 :(得分:3)

我的解决方案:在迁移到所需的postgres bin目录之前定义PATH变量

export PATH="/usr/lib/postgresql/9.3/bin/:$PATH"
rake db:migrate