PostgreSQL + Rails citext

前端 未结 5 770
粉色の甜心
粉色の甜心 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:48

    For anyone wanting to change an existing string column to citext, try creating a migration

    rails g migration change_username_from_string_to_citext
    

    Then make the migration look like this

    class ChangeUsernameFromStringToCitext < ActiveRecord::Migration[6.0]
      def change
        enable_extension("citext") # Don't forget this line
        change_column :users, :username, :citext
      end
    end
    

提交回复
热议问题