2016-12-17 16:59:11 +01:00
|
|
|
# Migrate tags from inline attribute to separate table
|
|
|
|
class PopulateTags < ActiveRecord::Migration
|
|
|
|
def self.up
|
2016-12-17 18:18:01 +01:00
|
|
|
change_column_null :events, :tags, true
|
|
|
|
change_column_null :orgas, :tags, true
|
|
|
|
|
2016-12-17 16:59:11 +01:00
|
|
|
execute('SELECT id, tags FROM events;').each do |result|
|
|
|
|
event = Event.find_by id: result[0]
|
2016-12-17 17:24:05 +01:00
|
|
|
event.tag_list = result[1]
|
2016-12-17 16:59:11 +01:00
|
|
|
event.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
2016-12-17 17:22:36 +01:00
|
|
|
change_column_null :events, :tags, false
|
|
|
|
change_column_null :orgas, :tags, false
|
2016-12-17 16:59:11 +01:00
|
|
|
end
|
|
|
|
end
|