1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/db/migrate/20160725131950_singleize_event_categories.rb

19 lines
501 B
Ruby

class SingleizeEventCategories < ActiveRecord::Migration
def up
execute 'UPDATE events AS e
SET category_id = ec.category_id
FROM events_categories AS ec
WHERE e.id = ec.event_id;'
end
def down
execute 'INSERT INTO events_categories
(event_id, category_id, created_at, updated_at)
SELECT id, category_id, now(), now()
FROM events;'
execute 'UPDATE events
SET category_id = NULL;'
end
end