问题描述
首先,我正在使用ar_firebird_adapter
,它是一个漂亮的适配器,它允许Rails和FB无缝集成(这是唯一与Rails 6兼容的适配器)。我遇到的问题是,一旦我连接到Firebird数据库并运行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
)
现在,我读到将rake db:structure:load
放入我的application.rb
后,需要使用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
时,这是我得到的错误:
struct collection
这是否意味着适配器不使用该rake命令,如果是,我该如何解决?这是我需要克服的巨大障碍!如果有人可以帮助我,我会很高兴。
解决方法
所以..答案很简单;尝试使用同一组家伙制造的另一个适配器!
我最终使用了firebird_adapter
,而db:schema:dump
的运作就像是一种魅力。
我确实不得不考虑gem中的一些未知数据类型,但是除此之外,一切都很好。
感谢那些看过/评论过的人。