Sha256: 36275f5c0a06b68f1efc5c29dfddefa3e15ba36254d988af733ecd0f7b9ad94b

Contents?: true

Size: 1.14 KB

Versions: 19

Compression:

Stored size: 1.14 KB

Contents

class RemoveSatelliteFromNotificationNameSpellCorrection < ActiveRecord::Migration[4.2]
  class FakeMailNotification < ActiveRecord::Base
    self.table_name = 'mail_notifications'

    has_many :user_mail_notifications, :dependent => :destroy, :class_name => 'FakeUserMailNotification', :foreign_key => 'mail_notification_id'
  end

  class FakeUserMailNotification < ActiveRecord::Base
    self.table_name = 'user_mail_notifications'
  end

  def up
    sync_errata_notification = FakeMailNotification.where(name: 'sync_errata').first
    satellite_sync_errata_notification = FakeMailNotification.where(name: 'satellite_sync_errata').first

    if sync_errata_notification && satellite_sync_errata_notification && FakeUserMailNotification.where(:mail_notification_id => sync_errata_notification.id).empty?
      satellite_sync_errata_notification.user_mail_notifications.each do |user_mail_notification|
        FakeUserMailNotification.create(:user_id => user_mail_notification.user_id, :mail_notification_id => sync_errata_notification.id)
      end
    end

    satellite_sync_errata_notification.destroy if satellite_sync_errata_notification.present?
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
foreman_theme_satellite-14.3.1 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.3.5 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.3.4 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-14.3.0 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-14.2.0 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.3.3 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-14.1.0 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.3.2 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.3.1 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-14.0.1 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-14.0.0 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.3.0 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.2.5 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.2.4 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.2.3 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.2.2 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.2.1 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.2.0 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb
foreman_theme_satellite-13.1.0 db/migrate/20161220092005_remove_satellite_from_notification_name_spell_correction.rb