开发者

Can I change my migrations depending on the database adapter? How will it reflects in the schema.rb?

开发者 https://www.devze.com 2023-01-21 21:32 出处:网络
Specifically, I want to add an spatial index in a multi_polygon column. This works nicely in PostgreSQL but not in MySQL, so I was thinking of somthing like:

Specifically, I want to add an spatial index in a multi_polygon column. This works nicely in PostgreSQL but not in MySQL, so I was thinking of somthing like:

create_table :figures do |t|
  t.multi_polygon :polygon
end

add_index :figures, :polygon if database_adapter == :postgresql

Is it possible and 开发者_JS百科a good idea?


You can pass index this way

add_index(:figures, [:polygon,:extra1,:extra2], :name => 'fig_poly')

This will work on mysql,postgresql,oracle and db2.

0

精彩评论

暂无评论...
验证码 换一张
取 消