【发布时间】:2020-12-30 10:17:55
【问题描述】:
首先,我使用ar_firebird_adapter,这是一个漂亮的适配器,它允许Rails 和FB 相当无缝地集成(唯一与Rails 6 兼容的适配器)。我遇到的问题是,一旦我连接到我的 Firebird DB 并运行rake db:schema:dump,一些表就会像这样出现:
# Could not dump table "country" because of following StandardError
# Unknown type 'VARCHAR' for column 'currency'
# Could not dump table "customer" because of following StandardError
# Unknown type 'VARCHAR' for column 'customer'
# Could not dump table "department" because of following StandardError
# Unknown type 'VARCHAR' for column 'department'
# Could not dump table "employee" because of following StandardError
# Unknown type 'VARCHAR' for column 'phone_ext'
create_table "employee_project", primary_key: ["proj_id", "emp_no"], force: :cascade do |t|
t.boolean "emp_no", null: false
t.boolean "proj_id", null: false
t.index ["emp_no", "proj_id"], name: "rdb$primary14", unique: true
t.index ["emp_no"], name: "rdb$foreign15"
t.index ["proj_id"], name: "rdb$foreign16"
end
# Could not dump table "job" because of following StandardError
# Unknown type 'VARCHAR' for column 'job_title'
# Could not dump table "proj_dept_budget" because of following StandardError
# Unknown type 'INTEGER' for column 'fiscal_year'
# Could not dump table "project" because of following StandardError
# Unknown type 'VARCHAR' for column 'proj_name'
如您所见,任何明确且没有“未知”类型的数据库都可以正常使用,但上述类型被列为StandardError(包括TIMESTAMP)
现在,我读到在将其放入我的application.rb 后,我需要使用rake db:structure:load:
config.active_record.schema_format = :sql
问题是,当我使用rake db:structure:load 时,这是我得到的错误:
rake aborted!
ActiveRecord::Tasks::DatabaseNotSupported: Rake tasks not supported by 'ar_firebird' adapter
Tasks: TOP => db:structure:dump
这是否意味着适配器不使用该 rake 命令,如果是,我该如何解决?这是我需要克服的巨大障碍!如果有人可以帮助我,我会很高兴。
【问题讨论】:
-
看起来您正在使用 Firebird 中包含的示例员工数据库。请注意,此示例数据库使用数组列,Firebird 的许多工具和驱动程序不支持这些列(尽管这似乎不是这里的问题)。
-
感谢您链接该标记。是的先生,您对这是示例数据库是正确的。我想确保在我去我们的实时数据库之前,我可以成功地转储到 Rails 中。你有什么想法吗?
-
很遗憾,我没有使用 Rails 的经验,因此无法提供帮助。
-
我们可以建议您
Varchar数据类型是什么,它具有什么属性,如何解释 FB API 或“系统表”的输出 - 但您需要将其编码到您的 Ruby 库中使用或寻找一些感兴趣的 Rubbist,他们会...
标签: ruby-on-rails api schema firebird