Skip to content

Migration for versions before #fc5199e

Stas Sușcov edited this page Oct 24, 2013 · 1 revision

With #fc5199e easy_auth changed the uid column type on identities from string to array.

In order to preserve the backwards compatibily during upgrades, you might find this migration useful:

class UpdateToEasyAuthArrayIdentities < ActiveRecord::Migration
  def change
    rename_column :identities, :uid, :old_uid
    add_column :identities, :uid, :string, array: true, default: []
    add_index :identities, :uid, using: 'gin'

    Identity.all.each do |ident|
      ident.uid = [ident.old_uid]
      ident.save
    end

    remove_column :identities, :old_uid
  end
end
Clone this wiki locally