From 606c812dca7c0f88d285d1d7003e7a6191efe688 Mon Sep 17 00:00:00 2001 From: echarp Date: Sat, 17 Dec 2016 18:18:01 +0100 Subject: [PATCH] Corrected migration, to populate the new tags table --- db/migrate/20161210154558_populate_tags.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/migrate/20161210154558_populate_tags.rb b/db/migrate/20161210154558_populate_tags.rb index 013ffd4e..7ae753a7 100644 --- a/db/migrate/20161210154558_populate_tags.rb +++ b/db/migrate/20161210154558_populate_tags.rb @@ -1,14 +1,14 @@ # Migrate tags from inline attribute to separate table class PopulateTags < ActiveRecord::Migration def self.up + change_column_null :events, :tags, true + change_column_null :orgas, :tags, true + execute('SELECT id, tags FROM events;').each do |result| event = Event.find_by id: result[0] event.tag_list = result[1] event.save end - - change_column_null :events, :tags, true - change_column_null :orgas, :tags, true end def self.down