尝试在PostgreSQL上运行rake db:migrate时出错

时间:2014-03-29 21:09:12

标签: ruby-on-rails ruby postgresql rake rake-task

我已将我的网站安装在新服务器上并安装了postgresql。现在我想耙数据库。并得到以下错误:

我在CentOS 6.5上使用ruby 1.93和Ruby on Rails 3

[root@digihaul3-pc current]# rake db:migrate
rake aborted!
PG::Error: ERROR:  relation "geometry_columns" does not exist
LINE 1: SELECT * FROM geometry_columns WHERE f_table_name='schema_mi...
                      ^
: SELECT * FROM geometry_columns WHERE f_table_name='schema_migrations'

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

将整个数据库文件夹上传到我的某个网站...您可以在此处查看http://www.digihaul.com/stackoverflow

这是正确的抱歉文件

# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20130811174830) do

  create_table "archived_loads", :id => false, :force => true do |t|
    t.integer  "id"
    t.integer  "user_id"
    t.spatial  "origin",       :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.spatial  "dest",         :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.integer  "length"
    t.string   "comments"
    t.boolean  "ltl"
    t.decimal  "rate"
    t.datetime "delivery"
    t.datetime "pickup"
    t.integer  "weight"
    t.integer  "equipment_id"
    t.boolean  "covered"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "owner"
    t.boolean  "deleted"
    t.string   "origin_city"
    t.string   "origin_state"
    t.string   "dest_city"
    t.string   "dest_state"
  end

  create_table "archived_trucks", :id => false, :force => true do |t|
    t.integer  "id"
    t.integer  "user_id"
    t.spatial  "origin",       :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.spatial  "dest",         :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.boolean  "covered"
    t.datetime "available"
    t.datetime "expiration"
    t.integer  "equipment_id"
    t.string   "comments"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "owner"
    t.boolean  "deleted"
    t.string   "origin_city"
    t.string   "origin_state"
    t.string   "dest_city"
    t.string   "dest_state"
  end

  create_table "autopost_headers", :force => true do |t|
    t.integer  "company_id"
    t.string   "pickup"
    t.string   "delivery"
    t.string   "dest"
    t.string   "origin"
    t.string   "available"
    t.string   "expiration"
    t.string   "rate"
    t.string   "length"
    t.string   "equipment"
    t.string   "weight"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "companies", :force => true do |t|
    t.string   "name"
    t.string   "city"
    t.string   "state"
    t.string   "zip"
    t.string   "address"
    t.boolean  "status"
    t.integer  "mc"
    t.string   "dispatch"
    t.string   "fax"
    t.datetime "created_at",   :null => false
    t.datetime "updated_at",   :null => false
    t.string   "credit_score"
  end

  create_table "credit_scores", :force => true do |t|
    t.string   "mc"
    t.string   "fbc"
    t.string   "dbt"
    t.string   "xp"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "documents", :force => true do |t|
    t.integer  "user_id"
    t.string   "name"
    t.string   "description"
    t.string   "filename"
    t.string   "filetype"
    t.integer  "filesize"
    t.datetime "created_at",  :null => false
    t.datetime "updated_at",  :null => false
  end

  create_table "equipment", :force => true do |t|
    t.string   "code"
    t.string   "name"
    t.string   "description"
    t.string   "altcode"
    t.boolean  "special_type"
    t.datetime "created_at",   :null => false
    t.datetime "updated_at",   :null => false
    t.integer  "parent_id"
  end

  create_table "equipment_notifications", :id => false, :force => true do |t|
    t.integer "equipment_id",    :null => false
    t.integer "notification_id", :null => false
  end

  add_index "equipment_notifications", ["equipment_id", "notification_id"], :name => "index_eq_not_on_equipment_id_and_notification_id", :unique => true
  add_index "equipment_notifications", ["notification_id", "equipment_id"], :name => "index_eq_not_on_notification_id_and_equipment_id", :unique => true

  create_table "equipment_searches", :id => false, :force => true do |t|
    t.integer "equipment_id", :null => false
    t.integer "search_id",    :null => false
  end

  add_index "equipment_searches", ["equipment_id", "search_id"], :name => "index_equipment_searches_on_equipment_id_and_search_id", :unique => true
  add_index "equipment_searches", ["search_id", "equipment_id"], :name => "index_equipment_searches_on_search_id_and_equipment_id", :unique => true

  create_table "lane_analyses", :force => true do |t|
    t.spatial  "origin",       :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.spatial  "dest",         :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.integer  "company_id"
    t.integer  "equipment_id"
    t.integer  "length"
    t.boolean  "ltl"
    t.datetime "created_at",                                                               :null => false
    t.datetime "updated_at",                                                               :null => false
  end

  add_index "lane_analyses", ["company_id"], :name => "index_lane_analyses_on_company_id"
  add_index "lane_analyses", ["dest"], :name => "index_lane_analyses_on_dest", :spatial => true
  add_index "lane_analyses", ["equipment_id"], :name => "index_lane_analyses_on_equipment_id"
  add_index "lane_analyses", ["origin"], :name => "index_lane_analyses_on_origin", :spatial => true

  create_table "leads", :force => true do |t|
    t.integer  "user_id"
    t.integer  "type_id"
    t.string   "post_type"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  add_index "leads", ["type_id"], :name => "index_leads_on_type_id"
  add_index "leads", ["user_id"], :name => "index_leads_on_user_id"

  create_table "loads", :force => true do |t|
    t.integer  "user_id"
    t.spatial  "origin",       :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.spatial  "dest",         :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.integer  "length"
    t.string   "comments"
    t.boolean  "ltl"
    t.decimal  "rate"
    t.datetime "delivery"
    t.datetime "pickup"
    t.integer  "weight"
    t.integer  "equipment_id"
    t.boolean  "covered",                                                                  :default => false, :null => false
    t.datetime "created_at",                                                                                  :null => false
    t.datetime "updated_at",                                                                                  :null => false
    t.integer  "owner"
    t.boolean  "deleted",                                                                  :default => false
    t.string   "origin_city"
    t.string   "origin_state"
    t.string   "dest_city"
    t.string   "dest_state"
  end

  add_index "loads", ["dest"], :name => "index_loads_on_dest", :spatial => true
  add_index "loads", ["equipment_id"], :name => "index_loads_on_equipment_id"

  create_table "locations", :force => true do |t|
    t.spatial  "coords",     :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.string   "city"
    t.string   "state"
    t.string   "zip"
    t.datetime "created_at",                                                             :null => false
    t.datetime "updated_at",                                                             :null => false
    t.string   "cs"
  end

  create_table "messages", :force => true do |t|
    t.integer  "user_id"
    t.string   "message"
    t.integer  "notifier_id"
    t.boolean  "received",    :default => false
    t.datetime "expiration"
    t.datetime "created_at",                     :null => false
    t.datetime "updated_at",                     :null => false
  end

  create_table "notifications", :force => true do |t|
    t.integer  "user_id"
    t.spatial  "origin",            :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.spatial  "dest",              :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.integer  "length"
    t.boolean  "ltl"
    t.integer  "rate"
    t.datetime "delivery"
    t.datetime "pickup"
    t.integer  "weight"
    t.datetime "available"
    t.datetime "expiration"
    t.datetime "created_at",                                                                    :null => false
    t.datetime "updated_at",                                                                    :null => false
    t.integer  "radius"
    t.string   "notification_type"
  end

  create_table "reports", :force => true do |t|
    t.string   "name"
    t.string   "metric"
    t.integer  "value"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "searches", :force => true do |t|
    t.datetime "available"
    t.datetime "pickup"
    t.datetime "delivery"
    t.decimal  "rate"
    t.integer  "length"
    t.integer  "user_id"
    t.integer  "weight"
    t.string   "search_type"
    t.boolean  "ltl"
    t.datetime "created_at",                            :null => false
    t.datetime "updated_at",                            :null => false
    t.datetime "expiration"
    t.string   "pickup_operator",     :default => ">="
    t.string   "delivery_operator",   :default => "<="
    t.string   "expiration_operator", :default => "<="
    t.string   "available_operator",  :default => ">="
    t.string   "length_operator",     :default => "<="
    t.string   "rate_operator",       :default => "<="
    t.string   "weight_operator",     :default => "<="
    t.string   "origin_zip"
    t.string   "dest_zip"
    t.integer  "origin_radius"
    t.integer  "dest_radius"
    t.boolean  "saved"
    t.date     "date_posted"
    t.string   "order_by"
    t.integer  "origin_id"
    t.integer  "dest_id"
    t.integer  "results",             :default => 0
    t.string   "origin_states"
    t.string   "dest_states"
  end

  add_index "searches", ["dest_id"], :name => "index_searches_on_dest"
  add_index "searches", ["origin_id"], :name => "index_searches_on_origin"

  create_table "subscriptions", :force => true do |t|
    t.integer  "company_id"
    t.decimal  "price"
    t.integer  "tier_id"
    t.string   "recurrence"
    t.datetime "created_at",        :null => false
    t.datetime "updated_at",        :null => false
    t.string   "paysysid"
    t.integer  "billing_date"
    t.datetime "last_payment_date"
  end

  create_table "testimonials", :force => true do |t|
    t.string   "customer"
    t.text     "description"
    t.datetime "created_at",                     :null => false
    t.datetime "updated_at",                     :null => false
    t.boolean  "approved",    :default => false
  end

  create_table "tiers", :force => true do |t|
    t.string   "name"
    t.string   "desc"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "trucks", :force => true do |t|
    t.integer  "user_id"
    t.spatial  "origin",       :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.spatial  "dest",         :limit => {:srid=>4326, :type=>"point", :geographic=>true}
    t.boolean  "covered",                                                                  :default => false, :null => false
    t.datetime "available"
    t.datetime "expiration"
    t.integer  "equipment_id"
    t.string   "comments"
    t.datetime "created_at",                                                                                  :null => false
    t.datetime "updated_at",                                                                                  :null => false
    t.integer  "owner"
    t.boolean  "deleted",                                                                  :default => false
    t.string   "origin_city"
    t.string   "origin_state"
    t.string   "dest_city"
    t.string   "dest_state"
  end

  create_table "user_preferences", :force => true do |t|
    t.integer  "user_id"
    t.integer  "radius",                 :default => 175
    t.integer  "page_size",              :default => 10
    t.text     "view",                   :default => "table"
    t.boolean  "can_be_email_notified",  :default => false
    t.boolean  "can_be_sms_notified",    :default => false
    t.integer  "max_sms",                :default => 0
    t.integer  "max_email",              :default => 0
    t.integer  "emailed_today",          :default => 0
    t.integer  "smsd_today",             :default => 0
    t.boolean  "can_be_screen_notified", :default => false
    t.datetime "created_at",                                  :null => false
    t.datetime "updated_at",                                  :null => false
    t.text     "provider",               :default => ""
    t.string   "default_sound"
  end

  create_table "users", :force => true do |t|
    t.integer  "company_id"
    t.string   "username"
    t.string   "password"
    t.string   "email"
    t.string   "dispatch"
    t.string   "fax"
    t.string   "sms"
    t.boolean  "status"
    t.boolean  "company_manager"
    t.datetime "created_at",                             :null => false
    t.datetime "updated_at",                             :null => false
    t.string   "encrypted_password",     :default => "", :null => false
    t.string   "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",          :default => 0
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string   "current_sign_in_ip"
    t.string   "last_sign_in_ip"
  end

end

这是结果

postgres=# DROP EXTENSION postgis;
ERROR:  extension "postgis" does not exist
postgres=# CREATE EXTENSION postgis;
ERROR:  type "spheroid" already exists
postgres=# DROP EXTENSION postgis;
ERROR:  extension "postgis" does not exist
postgres=# CREATE SCHEMA postgis;
ERROR:  schema "postgis" already exists
postgres=# CREATE EXTENSION postgis WITH SCHEMA postgis;
ERROR:  could not load library "/usr/pgsql-9.3/lib/rtpostgis-2.1.so": libhdf5.so.6: cannot open shared object file: No such file or directory

我用find -name查找文件:

[root@digihaul3-pc /]# find -name rtpostgis-2.1.so
./usr/pgsql-9.3/lib/rtpostgis-2.1.so

[root@digihaul3-pc /]# find -name libhdf5.so.6
./usr/lib64/mpich2/lib/libhdf5.so.6
./usr/pgsql-9.3/lib/libhdf5.so.6
./usr/lib/mpich2/lib/libhdf5.so.6

仅显示未找到或空白的那些 如你所见依赖在那里两次。

[root@digihaul3-pc /]# ldd /usr/pgsql-9.3/lib/rtpostgis-2.1.so
        linux-vdso.so.1 =>  (0x00007fffcd9ff000)
        libhdf5.so.6 => not found
        libhdf5_hl.so.6 => not found
        libhdf5.so.6 => not found

1 个答案:

答案 0 :(得分:1)

  

PG ::错误:错误:关系&#34; geometry_columns&#34;第1行不存在:   SELECT * FROM geometry_columns WHERE f_table_name =&#39; schema_mi ...                         ^:SELECT * FROM geometry_columns WHERE f_table_name =&#39; schema_migrations&#39;

根据错误,您的数据库中不存在geometry_columns表 这似乎与PostGIS安装有关,可能与您需要至少运行一次的CREATE EXTENSION postgis;查询有关。

请参阅此处的PostGIS说明。

修改

请尝试以下步骤:

DROP EXTENSION postgis;
CREATE SCHEMA postgis;
CREATE EXTENSION postgis WITH SCHEMA postgis;