2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2017-06-05 11:59:27 +05:30
|
|
|
class MoveConferencesToOrganizations < ActiveRecord::Migration
|
|
|
|
|
class TempConference < ActiveRecord::Base
|
|
|
|
|
self.table_name = 'conferences'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
class TempOrganization < ActiveRecord::Base
|
|
|
|
|
self.table_name = 'organizations'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def change
|
2017-06-07 12:37:30 +05:30
|
|
|
add_reference :conferences, :organization, index: true
|
2017-06-05 11:59:27 +05:30
|
|
|
|
|
|
|
|
TempConference.reset_column_information
|
2025-08-12 16:44:20 +02:00
|
|
|
if TempConference.any?
|
2017-06-06 20:04:39 +05:30
|
|
|
organization = TempOrganization.create(name: 'organization', description: 'Default organization')
|
|
|
|
|
TempConference.all.each do |conference|
|
|
|
|
|
conference.organization_id = organization.id
|
|
|
|
|
conference.save!
|
|
|
|
|
end
|
2017-06-05 11:59:27 +05:30
|
|
|
end
|
2017-06-07 12:37:30 +05:30
|
|
|
|
|
|
|
|
add_foreign_key :conferences, :organizations, null: false, on_delete: :cascade
|
2017-06-05 11:59:27 +05:30
|
|
|
end
|
|
|
|
|
end
|