我可以根据数据库适配器更改迁移吗?它将如何反映在schema.rb中?
-
10-10-2019 - |
题
具体来说,我想添加一个 spatial
索引 multi_polygon
柱子。这很好地工作 Postgresql 但不在 mysql, ,所以我在想像:
create_table :figures do |t|
t.multi_polygon :polygon
end
add_index :figures, :polygon if database_adapter == :postgresql
有可能还是个好主意?
解决方案
您可以通过这种方式通过索引
add_index(:figures,[:polygon,:extra1,:extra2],:name =>'fig_poly')
这将在MySQL,PostgreSQL,Oracle和DB2上使用。
不隶属于 StackOverflow