Sha256: be0cbcb8e9c8ace35b4ea62122c3d6ea30b984a7d611e7b9861a653abfe6d4e4

Contents?: true

Size: 914 Bytes

Versions: 2

Compression:

Stored size: 914 Bytes

Contents

class DeviseInvitableAddTo<%= table_name.camelize %> < ActiveRecord::Migration
  def self.up
    change_table :<%= table_name %> do |t|
      t.string   :invitation_token, :limit => 60
      t.datetime :invitation_sent_at
      t.integer  :invitation_limit
      t.integer  :invited_by_id
      t.index    :invitation_token # for invitable
      t.index    :invited_by_id
    end
    
    # And allow null encrypted_password and password_salt:
    change_column_null :<%= table_name %>, :encrypted_password, true
<% if class_name.constantize.columns_hash['password_salt'] -%>
    change_column_null :<%= table_name %>, :password_salt,      true
<% end -%>
  end
  
  def self.down
    remove_column :<%= table_name %>, :invited_by_id
    remove_column :<%= table_name %>, :invitation_limit
    remove_column :<%= table_name %>, :invitation_sent_at
    remove_column :<%= table_name %>, :invitation_token
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise_invitable-0.4.rc3 lib/generators/active_record/templates/migration.rb
devise_invitable-0.4.rc2 lib/generators/active_record/templates/migration.rb