mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-05 16:24:21 +01:00
19 lines
501 B
Ruby
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
|