heartcombo--devise/lib/generators/active_record/templates/migration_existing.rb

28 lines
998 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
def self.up
2016-01-30 17:20:32 +00:00
change_table :<%= table_name %> do |t|
2011-12-05 10:28:04 +00:00
<%= migration_data -%>
<% attributes.each do |attribute| -%>
t.<%= attribute.type %> :<%= attribute.name %>
<% end -%>
# Uncomment below if timestamps were not included in your original model.
2015-02-03 02:02:52 +00:00
# t.timestamps null: false
end
2014-02-25 16:42:55 +00:00
add_index :<%= table_name %>, :email, unique: true
add_index :<%= table_name %>, :reset_password_token, unique: true
# add_index :<%= table_name %>, :confirmation_token, unique: true
# add_index :<%= table_name %>, :unlock_token, unique: true
end
def self.down
# By default, we don't want to make any assumption about how to roll back a migration when your
# model already existed. Please edit below which fields you would like to remove in this migration.
raise ActiveRecord::IrreversibleMigration
end
end