User/Person models merge
This commit is contained in:
parent
66b84e3660
commit
23bf55b66c
80 changed files with 1064 additions and 1221 deletions
13
db/migrate/20140609172219_add_person_attributes_to_user.rb
Normal file
13
db/migrate/20140609172219_add_person_attributes_to_user.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class AddPersonAttributesToUser < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :name, :string
|
||||
add_column :users, :email_public, :boolean
|
||||
add_column :users, :biography, :string
|
||||
add_column :users, :nickname, :string
|
||||
add_column :users, :affiliation, :string
|
||||
add_column :users, :avatar_file_name, :string
|
||||
add_column :users, :avatar_content_type, :string
|
||||
add_column :users, :avatar_file_size, :integer
|
||||
add_column :users, :avatar_updated_at, :datetime
|
||||
end
|
||||
end
|
||||
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
|
||||
28
db/migrate/20140610165551_migrate_data_person_to_user.rb
Normal file
28
db/migrate/20140610165551_migrate_data_person_to_user.rb
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
class MigrateDataPersonToUser < ActiveRecord::Migration
|
||||
class TempPerson < ActiveRecord::Base
|
||||
self.table_name = 'people'
|
||||
end
|
||||
|
||||
class TempUser < ActiveRecord::Base
|
||||
self.table_name = 'users'
|
||||
end
|
||||
|
||||
def change
|
||||
TempPerson.all.each do |p|
|
||||
user = TempUser.find(p.user_id)
|
||||
if p.public_name.empty?
|
||||
user.name = p.email
|
||||
else
|
||||
user.name = p.public_name
|
||||
end
|
||||
user.biography = p.biography
|
||||
user.nickname = p.irc_nickname
|
||||
user.affiliation = p.company
|
||||
user.avatar_file_name = p.avatar_file_name
|
||||
user.avatar_content_type = p.avatar_content_type
|
||||
user.avatar_file_size = p.avatar_file_size
|
||||
user.avatar_updated_at = p.avatar_updated_at
|
||||
user.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
class ChangePersonIdToUserIdInRegistrations < ActiveRecord::Migration
|
||||
class TempPerson < ActiveRecord::Base
|
||||
self.table_name = 'people'
|
||||
end
|
||||
|
||||
class TempRegistration < ActiveRecord::Base
|
||||
self.table_name = 'registrations'
|
||||
end
|
||||
|
||||
def change
|
||||
add_column :registrations, :user_id, :integer
|
||||
|
||||
TempPerson.all.each do |t|
|
||||
registrations = TempRegistration.where(person_id: t.id)
|
||||
|
||||
unless registrations.empty?
|
||||
registrations.each do |r|
|
||||
r.user_id = t.user_id
|
||||
r.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
remove_column :registrations, :person_id
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
class ChangePersonIdToUserIdInVotes < ActiveRecord::Migration
|
||||
class TempPerson < ActiveRecord::Base
|
||||
self.table_name = 'people'
|
||||
end
|
||||
|
||||
class TempVote < ActiveRecord::Base
|
||||
self.table_name = 'votes'
|
||||
end
|
||||
|
||||
def change
|
||||
add_column :votes, :user_id, :integer
|
||||
|
||||
TempPerson.all.each do |t|
|
||||
votes = TempVote.where(person_id: t.id)
|
||||
|
||||
unless votes.empty?
|
||||
votes.each do |v|
|
||||
v.user_id = t.user_id
|
||||
v.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
remove_column :votes, :person_id
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
class DropPersonAndEventPersonTables < ActiveRecord::Migration
|
||||
def change
|
||||
drop_table :people
|
||||
drop_table :event_people
|
||||
end
|
||||
end
|
||||
61
db/schema.rb
61
db/schema.rb
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140625114813) do
|
||||
ActiveRecord::Schema.define(version: 20140626123837) do
|
||||
|
||||
create_table "ahoy_events", force: true do |t|
|
||||
t.uuid "visit_id"
|
||||
|
|
@ -21,7 +21,7 @@ ActiveRecord::Schema.define(version: 20140625114813) do
|
|||
t.datetime "time"
|
||||
end
|
||||
|
||||
#add_index "ahoy_events", ["id"], name: "sqlite_autoindex_ahoy_events_1", unique: true
|
||||
# add_index "ahoy_events", ["id"], name: "sqlite_autoindex_ahoy_events_1", unique: true
|
||||
add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time"
|
||||
add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id"
|
||||
add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id"
|
||||
|
|
@ -178,16 +178,6 @@ ActiveRecord::Schema.define(version: 20140625114813) do
|
|||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "event_people", force: true do |t|
|
||||
t.integer "proposal_id"
|
||||
t.integer "person_id"
|
||||
t.integer "event_id"
|
||||
t.string "event_role", default: "participant", null: false
|
||||
t.string "comment"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "event_types", force: true do |t|
|
||||
t.integer "conference_id"
|
||||
t.string "title", null: false
|
||||
|
|
@ -197,6 +187,15 @@ ActiveRecord::Schema.define(version: 20140625114813) do
|
|||
t.string "color"
|
||||
end
|
||||
|
||||
create_table "event_users", force: true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "event_id"
|
||||
t.string "event_role", default: "participant", null: false
|
||||
t.string "comment"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "events", force: true do |t|
|
||||
t.string "guid", null: false
|
||||
t.integer "conference_id"
|
||||
|
|
@ -254,29 +253,6 @@ ActiveRecord::Schema.define(version: 20140625114813) do
|
|||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "people", force: true do |t|
|
||||
t.string "guid", null: false
|
||||
t.string "first_name", default: ""
|
||||
t.string "last_name", default: ""
|
||||
t.string "public_name", default: ""
|
||||
t.string "company", default: ""
|
||||
t.string "email", null: false
|
||||
t.boolean "email_public"
|
||||
t.string "avatar_file_name"
|
||||
t.string "avatar_content_type"
|
||||
t.integer "avatar_file_size"
|
||||
t.datetime "avatar_updated_at"
|
||||
t.text "biography"
|
||||
t.integer "user_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "irc_nickname"
|
||||
t.text "volunteer_experience"
|
||||
t.string "tshirt"
|
||||
t.string "mobile"
|
||||
t.string "languages"
|
||||
end
|
||||
|
||||
create_table "photos", force: true do |t|
|
||||
t.text "description"
|
||||
t.string "picture_file_name"
|
||||
|
|
@ -314,7 +290,6 @@ ActiveRecord::Schema.define(version: 20140625114813) do
|
|||
end
|
||||
|
||||
create_table "registrations", force: true do |t|
|
||||
t.integer "person_id"
|
||||
t.integer "conference_id"
|
||||
t.boolean "attending_social_events", default: true
|
||||
t.boolean "attending_with_partner", default: false
|
||||
|
|
@ -330,6 +305,7 @@ ActiveRecord::Schema.define(version: 20140625114813) do
|
|||
t.boolean "attended", default: false
|
||||
t.boolean "volunteer"
|
||||
t.integer "week"
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
create_table "registrations_social_events", id: false, force: true do |t|
|
||||
|
|
@ -445,6 +421,15 @@ ActiveRecord::Schema.define(version: 20140625114813) do
|
|||
t.string "unconfirmed_email"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "name"
|
||||
t.boolean "email_public"
|
||||
t.text "biography"
|
||||
t.string "nickname"
|
||||
t.string "affiliation"
|
||||
t.string "avatar_file_name"
|
||||
t.string "avatar_content_type"
|
||||
t.integer "avatar_file_size"
|
||||
t.datetime "avatar_updated_at"
|
||||
end
|
||||
|
||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
|
|
@ -517,15 +502,15 @@ ActiveRecord::Schema.define(version: 20140625114813) do
|
|||
t.datetime "started_at"
|
||||
end
|
||||
|
||||
#add_index "visits", ["id"], name: "sqlite_autoindex_visits_1", unique: true
|
||||
# add_index "visits", ["id"], name: "sqlite_autoindex_visits_1", unique: true
|
||||
add_index "visits", ["user_id"], name: "index_visits_on_user_id"
|
||||
|
||||
create_table "votes", force: true do |t|
|
||||
t.integer "person_id"
|
||||
t.integer "event_id"
|
||||
t.integer "rating"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
create_table "vpositions", force: true do |t|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue