将 ar_firebird_adapter 的 Firebird 数据库表转储到 Rails schema.rb 中,但并非所有表都正确转储
Dumping Firebird DB tables with ar_firebird_adapter into Rails schema.rb and not all tables are dumping correctly
首先,我正在使用 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_adapter
并且 db:schema:dump
非常有效。
我确实不得不考虑 gem 中的一些未知数据类型,但除此之外,一切都很好。
感谢那些 looked/commented.
首先,我正在使用 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_adapter
并且 db:schema:dump
非常有效。
我确实不得不考虑 gem 中的一些未知数据类型,但除此之外,一切都很好。
感谢那些 looked/commented.