From eb8d8f47663d4c5c2d074b34e309dd0fd1bf15f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Sat, 12 Sep 2015 18:41:34 +0200 Subject: [PATCH] changes migration to update invalid orgs --- ...0912145218_add_responsible_name_to_organizations.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/db/migrate/20150912145218_add_responsible_name_to_organizations.rb b/db/migrate/20150912145218_add_responsible_name_to_organizations.rb index ffffd31ce..08598e7c4 100644 --- a/db/migrate/20150912145218_add_responsible_name_to_organizations.rb +++ b/db/migrate/20150912145218_add_responsible_name_to_organizations.rb @@ -1,5 +1,13 @@ class AddResponsibleNameToOrganizations < ActiveRecord::Migration - def change + def up add_column :organizations, :responsible_name, :string, limit: 60 + + Organization.find_each do |org| + org.update(responsible_name: org.name) if org.responsible_name.blank? + end + end + + def down + remove_column :organizations, :responsible_name end end