Sha256: 8a89b05418e1394cf8c227cc21fff2c66d052961d8f88036fbed2016e2078dad
Contents?: true
Size: 934 Bytes
Versions: 9
Compression:
Stored size: 934 Bytes
Contents
class AddClearanceToUsers < ActiveRecord::Migration<%= migration_version %> def self.up <% if config[:new_columns].any? -%> change_table :users do |t| <% config[:new_columns].values.each do |column| -%> <%= column %> <% end -%> end <% end -%> <% if config[:new_indexes].any? -%> <% config[:new_indexes].values.each do |index| -%> <%= index %> <% end -%> <% end -%> <% if config[:new_columns].keys.include?(:remember_token) -%> Clearance.configuration.user_model.where(remember_token: nil).each do |user| user.update_columns(remember_token: Clearance::Token.new) end <% end -%> end def self.down <% config[:new_indexes].values.each do |index| -%> <%= index.sub("add_index", "remove_index") %> <% end -%> <% if config[:new_columns].any? -%> change_table :users do |t| <% config[:new_columns].keys.each do |key| -%> t.remove <%= key.inspect %> <% end -%> end <% end -%> end end
Version data entries
9 entries across 9 versions & 1 rubygems