Corrected migration, to populate the new tags table

This commit is contained in:
echarp 2016-12-17 18:18:01 +01:00
parent 4f8cf33f90
commit 606c812dca

View File

@ -1,14 +1,14 @@
# Migrate tags from inline attribute to separate table # Migrate tags from inline attribute to separate table
class PopulateTags < ActiveRecord::Migration class PopulateTags < ActiveRecord::Migration
def self.up def self.up
change_column_null :events, :tags, true
change_column_null :orgas, :tags, true
execute('SELECT id, tags FROM events;').each do |result| execute('SELECT id, tags FROM events;').each do |result|
event = Event.find_by id: result[0] event = Event.find_by id: result[0]
event.tag_list = result[1] event.tag_list = result[1]
event.save event.save
end end
change_column_null :events, :tags, true
change_column_null :orgas, :tags, true
end end
def self.down def self.down