【发布时间】:2017-07-01 10:53:04
【问题描述】:
我有一个项目目前使用旧版本的 Ruby on Rails 环境并使用 PostgreSQL 数据库。版本是(是的,我知道......别笑,我现在必须支持这个旧版本):
ruby 1.8.7
rails 2.3.11
rake 10.5.0
psql 9.5.7
如果重要的话,这一切都安装在 Ubuntu 16.04 系统上。这一切都在我拥有的旧系统上运行,最终死机。于是我在新机器上设置了rvm和这些开发工具版本,并复制了数据库。
在新机器上,一切似乎都运行良好除了我尝试过的几个 rake 数据库任务。例如,如果我运行rake db:schema:dump,我不会得到错误输出,并且会得到一个包含以下内容的db/schema.rb 文件:
# 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 => 0) do
end
我尝试运行rake db:structure:dump,但出现错误:
/usr/lib/postgresql/9.5/bin/pg_dump: invalid option -- 'i'
Try "pg_dump --help" for more information.
rake aborted!
Error dumping database
/home/mark/.rvm/gems/ruby-1.8.7-p374@caplus/gems/rails-2.3.11/lib/tasks/databases.rake:287
/home/mark/.rvm/gems/ruby-1.8.7-p374@caplus/bin/ruby_executable_hooks:15
Tasks: TOP => db:structure:dump
(See full trace by running task with --trace)
我主要担心的是缺乏转储架构的能力。我不明白它是如何运行没有错误的,但没有生成架构。正如我最初提到的,该应用程序通过script/server 运行良好。我还从控制台运行ActiveRecord::SchemaDumper.dump,得到完全相同的结果(我猜这是意料之中的,因为这可能是 rake 任务运行的内容)。但是从控制台,我可以很好地检查任何模型和数据。都在那里。
关于为什么架构文件为空的任何想法?我希望有人以前见过这种现象。我已经对rake db:schema:dump 的故障模式进行了大量搜索,但在任何地方都找不到提到的这种特殊症状。
【问题讨论】:
标签: ruby-on-rails rake