耙db:迁移不工作在我的postgres数据库

好吧,所以我有一个rails应用程序,我试图在postgres数据库上运行迁移,我通常使用mysql,所有都很好,但是当我运行命令时,我得到了这个

rake db:migrate
(in /Users/tamer/Sites/my_app)
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:487: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]

-- control frame ----------
c:0058 p:---- s:0215 b:0215 l:000214 d:000214 CFUNC  :exec
c:0057 p:0040 s:0211 b:0211 l:000191 d:000210 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter
c:0056 p:0005 s:0208 b:0208 l:000198 d:000207 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.r
c:0055 p:0032 s:0206 b:0206 l:000205 d:000205 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21
c:0054 p:0052 s:0199 b:0199 l:000198 d:000198 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.r
c:0053 p:0018 s:0192 b:0192 l:000191 d:000191 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter
c:0052 p:0013 s:0187 b:0187 l:000186 d:000186 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter
c:0051 p:0011 s:0184 b:0184 l:000183 d:000183 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter
c:0050 p:0136 s:0180 b:0180 l:000179 d:000179 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter
c:0049 p:0131 s:0177 b:0177 l:000176 d:000176 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter
c:0048 p:0054 s:0174 b:0174 l:000173 d:000173 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter
c:0047 p:---- s:0167 b:0167 l:000166 d:000166 FINISH
c:0046 p:---- s:0165 b:0165 l:000164 d:000164 CFUNC  :new
c:0045 p:0186 s:0158 b:0158 l:000157 d:000157 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter
c:0044 p:0045 s:0149 b:0149 l:000148 d:000148 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio
c:0043 p:0011 s:0146 b:0146 l:000145 d:000145 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio
c:0042 p:0048 s:0142 b:0142 l:000128 d:000141 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio
c:0041 p:---- s:0139 b:0139 l:000138 d:000138 FINISH
c:0040 p:---- s:0137 b:0137 l:000136 d:000136 CFUNC  :loop
c:0039 p:0009 s:0134 b:0134 l:000128 d:000133 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio
c:0038 p:0019 s:0132 b:0132 l:000131 d:000131 METHOD /Users/tamer/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201
c:0037 p:0013 s:0129 b:0129 l:000128 d:000128 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio
c:0036 p:0030 s:0126 b:0123 l:000122 d:000122 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio
c:0035 p:0033 s:0120 b:0120 l:000119 d:000119 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio
c:0034 p:0018 s:0115 b:0115 l:000114 d:000114 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio
c:0033 p:0011 s:0112 b:0112 l:000111 d:000111 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connectio
c:0032 p:0020 s:0109 b:0109 l:000108 d:000108 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:486
c:0031 p:---- s:0103 b:0103 l:000102 d:000102 FINISH
c:0030 p:---- s:0101 b:0101 l:000100 d:000100 CFUNC  :new
c:0029 p:0020 s:0095 b:0095 l:000094 d:000094 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:433
c:0028 p:0083 s:0090 b:0090 l:000089 d:000089 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:415
c:0027 p:0102 s:0085 b:0085 l:000d58 d:000084 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:142
c:0026 p:---- s:0083 b:0083 l:000082 d:000082 FINISH
c:0025 p:---- s:0081 b:0081 l:000080 d:000080 CFUNC  :call
c:0024 p:0043 s:0076 b:0076 l:000067 d:000075 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:636
c:0023 p:---- s:0073 b:0073 l:000072 d:000072 FINISH
c:0022 p:---- s:0071 b:0071 l:000070 d:000070 CFUNC  :each
c:0021 p:0171 s:0068 b:0068 l:000067 d:000067 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:631
c:0020 p:0110 s:0064 b:0064 l:000058 d:000063 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:597
c:0019 p:0019 s:0062 b:0062 l:000061 d:000061 METHOD /Users/tamer/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201
c:0018 p:0033 s:0059 b:0059 l:000058 d:000058 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:590
c:0017 p:0048 s:0053 b:0053 l:000052 d:000052 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:583
c:0016 p:0045 s:0048 b:0048 l:000047 d:000047 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2051
c:0015 p:0012 s:0041 b:0041 l:000026 d:000040 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2029
c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC  :each
c:0012 p:0069 s:0033 b:0033 l:000026 d:000032 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2029
c:0011 p:0009 s:0031 b:0031 l:000030 d:000030 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/airbrake-3.0.9/lib/airbrake/rake_handler.rb:33
c:0010 p:0011 s:0027 b:0027 l:000026 d:000026 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2023
c:0009 p:0029 s:0024 b:0024 l:000017 d:000023 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2001
c:0008 p:0009 s:0022 b:0022 l:000021 d:000021 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2068
c:0007 p:0011 s:0018 b:0018 l:000017 d:000017 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:1998
c:0006 p:0036 s:0015 b:0015 l:000014 d:000014 TOP    /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/bin/rake:31
c:0005 p:---- s:0013 b:0013 l:000012 d:000012 FINISH
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC  :load
c:0003 p:0127 s:0007 b:0007 l:0014e8 d:000f40 EVAL   /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/bin/rake:19
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0014e8 d:0014e8 TOP   
---------------------------
-- Ruby level backtrace information ----------------------------------------
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/bin/rake:19:in `<main>'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/bin/rake:19:in `load'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/bin/rake:31:in `<top (required)>'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/airbrake-3.0.9/lib/airbrake/rake_handler.rb:33:in `standard_exception_handling'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top_level'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 levels) in top_level'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/tamer/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:597:in `block in invoke_with_call_chain'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:142:in `block (2 levels) in <top (required)>'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:415:in `migrate'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:433:in `up'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:433:in `new'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/migration.rb:486:in `initialize'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in `retrieve_connection'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:316:in `retrieve_connection'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:93:in `connection'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `checkout'
/Users/tamer/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `block in checkout'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `loop'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `block (2 levels) in checkout'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `checkout_new_connection'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:228:in `new_connection'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `postgresql_connection'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `new'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:228:in `initialize'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:939:in `connect'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:956:in `configure_connection'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:278:in `set_standard_conforming_strings'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:699:in `client_min_messages'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:483:in `query'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:195:in `log'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:197:in `block in log'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:487:in `block in query'
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:487:in `exec'

-- C level backtrace information -------------------------------------------

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap

我的database.yml文件看起来像这样

development: 
encoding: unicode
adapter: postgresql
username: postgres
port: 5432
host: localhost
database: test
password: password

任何想法我做错了什么..这些都是正确的凭据,因为我用这些信誉与这个postgres数据库与GUI工具连接

我用这个链接来安装pg gem


鉴于你得到了一个实际的分段错误,我敢打赌你的pg gem和libpg一起出现问题。 最近有没有可能升级你的操作系统?

如果这似乎是一个合理的事情,你可以尝试保存数据库的备份,加入现有的pg安装(数据库,库和宝石),然后重新安装它们,希望消除不兼容问题导致的问题。


我在同一个应用程序中有mysql和postgresql数据库。 以下是我设置postgresql数据库所遵循的步骤。

  • 安装PostgreSQL及其库文件sudo apt-get install postgresql postgresql-contrib libpq-dev
  • 安装后为postgresql创建用户sudo -u postgres createuser --superuser $USERsudo -u postgres createuser pgs_root
  • 设置postgresql用户的用户密码sudo -u postgres psql postgres ( For psql prompt) postgres=# password <user>用于ex.- postgres=# passsword pgs_root
  • 配置postgresql.conf文件以使PostgreSQL监听localhost或监听外部IP或其他内容,将此行更改为IP或'localhost'gedit /etc/postgresql/8.4/main/postgresql.conf listen_addresses = 'localhost'
  • 为了让您的应用程序能够连接PostgreSQL中的数据库,请在database.yml中配置它

    development_postgres: adapter: postgresql database: connect_postgres username: pgs_root password: root123 host: 127.0.0.1

  • rake db:create RAILS_ENV=development_postgres

  • 像mysql查询浏览器一样,postgresql有一个名为pgadmin的GUI。 安装

    sudo apt-get install pgadmin3
    

    我会尝试以下方法:

  • 删除主机线
  • 运行软件包更新
  • 重命名数据库,以确保其新鲜
  • 运行rake db:create
  • 运行rake db:migrate
  • 我遇到过问题,我的pg gem不适合我的rails版本

    链接地址: http://www.djcxy.com/p/57557.html

    上一篇: rake db:migrate not working on my postgres db

    下一篇: Resque: one worker per queue