mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-10 21:24:20 +01:00
21 lines
536 B
Ruby
21 lines
536 B
Ruby
# frozen_string_literal:true
|
|
|
|
class SingleizeEventCategories < ActiveRecord::Migration[4.2]
|
|
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
|