PostgreSQL + Rails citext

前端 未结 5 771
粉色の甜心
粉色の甜心 2021-01-02 17:50

I am trying to move to heroku which uses PostgreSQL 8.4 which has a citext column type which is nice since the app was written for MySQL.

Is there any way to use :ci

5条回答
  •  一向
    一向 (楼主)
    2021-01-02 18:46

    Rails 4.2+

    Rails 4.2 has native support for the citext column type.

    Rails < 4.2

    If you're using Rails < 4.2, you can try using the activerecord-postgresql-citext gem.

    This allows you to write migrations like this:

    def up
      enable_extension("citext")                   
    
      create_table :models, :force => true do |t|  
        t.citext :name                             
        t.timestamps                               
      end                                          
    end
    

提交回复
热议问题