User/Person models merge
This commit is contained in:
parent
66b84e3660
commit
23bf55b66c
80 changed files with 1064 additions and 1221 deletions
35
db/migrate/20140610163947_create_event_users.rb
Normal file
35
db/migrate/20140610163947_create_event_users.rb
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
class CreateEventUsers < ActiveRecord::Migration
|
||||
class TempPerson < ActiveRecord::Base
|
||||
self.table_name = 'people'
|
||||
end
|
||||
|
||||
class TempEventPerson < ActiveRecord::Base
|
||||
self.table_name = 'event_people'
|
||||
end
|
||||
|
||||
class TempEventUser < ActiveRecord::Base
|
||||
self.table_name = 'event_users'
|
||||
end
|
||||
|
||||
def change
|
||||
create_table :event_users do |t|
|
||||
t.references :user
|
||||
t.references :event
|
||||
t.string :event_role, null: false, default: 'participant'
|
||||
t.string :comment
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
TempEventPerson.all.each do |ep|
|
||||
record = TempEventUser.new
|
||||
record.event_id = ep.event_id
|
||||
person = TempPerson.where(id: ep.person_id).first
|
||||
record.user_id = person.user_id
|
||||
record.event_role = ep.event_role
|
||||
record.comment = ep.comment
|
||||
record.save!
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue