Sha256: 669a7429be943ffe10630a82ba699e71972fda30cd3b06a555a0bb686c673c45

Contents?: true

Size: 974 Bytes

Versions: 5

Compression:

Stored size: 974 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.datetime   :invitation_accepted_at
      t.integer    :invitation_limit
      t.references :invited_by, :polymorphic => true
      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
    change_table :<%= table_name %> do |t|
      t.remove_references :invited_by, :polymorphic => true
      t.remove :invitation_limit, :invitation_sent_at, :invitation_accepted_at, :invitation_token
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
devise_invitable-0.6.1 lib/generators/active_record/templates/migration.rb
devise_invitable-0.6.0 lib/generators/active_record/templates/migration.rb
devise_invitable-0.5.7 lib/generators/active_record/templates/migration.rb
devise_invitable-0.5.6 lib/generators/active_record/templates/migration.rb
devise_invitable-0.5.5 lib/generators/active_record/templates/migration.rb