2021-12-19 07:51:04 -08:00
|
|
|
class CreateProfiles < ActiveRecord::Migration[5.2]
|
|
|
|
def change
|
|
|
|
create_table :profiles do |t|
|
|
|
|
t.references :user, index: true, foreign_key: true
|
2021-12-19 14:51:06 -08:00
|
|
|
t.string :display_name, length: 50
|
|
|
|
t.string :description, length: 200, null: false, default: ''
|
|
|
|
t.string :location, length: 72, null: false, default: ''
|
|
|
|
t.string :website, null: false, default: ''
|
|
|
|
t.string :motivation_header, null: false, default: ''
|
2021-12-19 07:51:04 -08:00
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
2021-12-22 23:56:50 -08:00
|
|
|
transaction do
|
|
|
|
execute 'INSERT INTO profiles (user_id, display_name, description, location, website, motivation_header, created_at, updated_at) SELECT users.id as user_id, users.display_name, users.bio as description, users.location, users.website, users.motivation_header, users.created_at, users.updated_at FROM users;'
|
|
|
|
|
|
|
|
remove_column :users, :display_name
|
|
|
|
remove_column :users, :bio
|
|
|
|
remove_column :users, :location
|
|
|
|
remove_column :users, :website
|
|
|
|
remove_column :users, :motivation_header
|
2021-12-19 07:51:04 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|