Moves sponsor email attribute from conference to contact
This commit is contained in:
parent
c0cdf3e6e5
commit
9376fe57e3
10 changed files with 49 additions and 11 deletions
26
db/migrate/20140930092923_move_sponsor_email_to_contact.rb
Normal file
26
db/migrate/20140930092923_move_sponsor_email_to_contact.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
class MoveSponsorEmailToContact < ActiveRecord::Migration
|
||||
class TempConference < ActiveRecord::Base
|
||||
self.table_name = 'conferences'
|
||||
end
|
||||
|
||||
class TempContact < ActiveRecord::Base
|
||||
self.table_name = 'contacts'
|
||||
end
|
||||
|
||||
def change
|
||||
add_column :contacts, :sponsor_email, :string
|
||||
|
||||
TempConference.all.each do |conference|
|
||||
contact = TempContact.find_by(conference_id: conference.id)
|
||||
if contact
|
||||
contact.sponsor_email = conference.sponsor_email
|
||||
contact.save
|
||||
else
|
||||
Contact.create(conference_id: conference.id,
|
||||
sponsors_email: conference.sponsor_email)
|
||||
end
|
||||
end
|
||||
|
||||
remove_column :conferences, :sponsor_email
|
||||
end
|
||||
end
|
||||
|
|
@ -105,7 +105,6 @@ ActiveRecord::Schema.define(version: 20141106141750) do
|
|||
t.boolean "use_difficulty_levels", default: false
|
||||
t.boolean "use_volunteers"
|
||||
t.string "color"
|
||||
t.string "sponsor_email"
|
||||
t.text "events_per_week"
|
||||
end
|
||||
|
||||
|
|
@ -124,6 +123,7 @@ ActiveRecord::Schema.define(version: 20141106141750) do
|
|||
t.integer "conference_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "sponsor_email"
|
||||
end
|
||||
|
||||
create_table "delayed_jobs", force: true do |t|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue