From e1f62d66687bf5f91d2726707bc2d8a9e9426862 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 3 Jun 2017 22:17:13 +0300 Subject: [PATCH] change migration to move old data over --- Guardfile | 2 +- ...2115219_add_street_city_country_to_user.rb | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Guardfile b/Guardfile index 48a389b..f93649f 100644 --- a/Guardfile +++ b/Guardfile @@ -57,7 +57,7 @@ end # * zeus: 'zeus rspec' (requires the server to be started separately) # * 'just' rspec: 'rspec' -guard :rspec, cmd: "bundle exec rspec" do +guard :rspec, cmd: "rspec" do require "guard/rspec/dsl" dsl = Guard::RSpec::Dsl.new(self) diff --git a/db/migrate/20170602115219_add_street_city_country_to_user.rb b/db/migrate/20170602115219_add_street_city_country_to_user.rb index a96c98a..eca1e15 100644 --- a/db/migrate/20170602115219_add_street_city_country_to_user.rb +++ b/db/migrate/20170602115219_add_street_city_country_to_user.rb @@ -1,7 +1,24 @@ class AddStreetCityCountryToUser < ActiveRecord::Migration[5.0] - def change + + def up add_column :users, :street, :string add_column :users, :city, :string add_column :users, :country, :string + puts "UP" + User.all.each do |user| + resume = user.resume + user.street = resume.street + user.city = resume.city + user.country = resume.country + user.save + end end + + def down + remove_column :users, :street + remove_column :users, :city + remove_column :users, :country + puts "DOWN" + end + end