Sha256: 808144878da942b10d66272ed165e2478d73dd8b8944da9e8c3f6d81e6baf737

Contents?: true

Size: 767 Bytes

Versions: 58

Compression:

Stored size: 767 Bytes

Contents

# frozen_string_literal: true

class MoveMeetingServicesToOwnModel < ActiveRecord::Migration[5.2]
  class Meeting < ApplicationRecord
    self.table_name = :decidim_meetings_meetings
  end

  class Service < ApplicationRecord
    self.table_name = :decidim_meetings_services
  end

  def change
    Meeting.reset_column_information
    Service.reset_column_information

    Meeting.find_each do |meeting|
      meeting["services"].each do |service|
        Service.create!(
          decidim_meeting_id: meeting.id,
          title: service["title"],
          description: service["description"]
        )
      end
    end

    remove_column :decidim_meetings_meetings, :services

    Meeting.reset_column_information
    Service.reset_column_information
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
decidim-meetings-0.29.1 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.28.4 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.27.9 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.29.0 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.28.3 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.27.8 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.29.0.rc4 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.29.0.rc3 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.29.0.rc2 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.29.0.rc1 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.28.2 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.27.7 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.28.1 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.27.6 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.26.10 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.26.9 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.28.0 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.27.5 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.28.0.rc5 db/migrate/20200702123210_move_meeting_services_to_own_model.rb
decidim-meetings-0.28.0.rc4 db/migrate/20200702123210_move_meeting_services_to_own_model.rb