parent
a620950383
commit
ed55e2bf3a
25 changed files with 529 additions and 131 deletions
16
db/migrate/20140804185823_create_registration_periods.rb
Normal file
16
db/migrate/20140804185823_create_registration_periods.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
class CreateRegistrationPeriods < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :registration_periods do |t|
|
||||
t.integer :conference_id
|
||||
t.date :start_date
|
||||
t.date :end_date
|
||||
t.text :description
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :registration_periods
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
class MoveConferenceRegistrationDataToRegistrationPeriods < ActiveRecord::Migration
|
||||
class TempConference < ActiveRecord::Base
|
||||
self.table_name = 'conferences'
|
||||
end
|
||||
|
||||
class TempRegistrationPeriod < ActiveRecord::Base
|
||||
self.table_name = 'registration_periods'
|
||||
attr_accessible :conference_id, :start_date, :end_date, :description
|
||||
end
|
||||
|
||||
def up
|
||||
# Move all the settings to the new object
|
||||
TempConference.all.each do |conference|
|
||||
unless TempRegistrationPeriod.exists?(conference_id: conference.id)
|
||||
TempRegistrationPeriod.create(conference_id: conference.id,
|
||||
start_date: conference.registration_start_date,
|
||||
end_date: conference.registration_end_date,
|
||||
description: conference.registration_description)
|
||||
end
|
||||
end
|
||||
|
||||
# Remove Columns
|
||||
remove_column :conferences, :registration_start_date
|
||||
remove_column :conferences, :registration_end_date
|
||||
remove_column :conferences, :registration_description
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :conferences, :registration_start_date, :date
|
||||
add_column :conferences, :registration_end_date, :date
|
||||
add_column :conferences, :registration_description, :text
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue