Sha256: 2c5af49f8f57e689c6541ba4de790baaab0fdf179a5b8cf262982215189c65cd

Contents?: true

Size: 544 Bytes

Versions: 3

Compression:

Stored size: 544 Bytes

Contents

class AddSourcesToShopSubscriptions < ActiveRecord::Migration[5.1]

  def change
    add_column :disco_app_subscriptions, :source_id, :integer, limit: 8, index: true
    add_foreign_key :disco_app_subscriptions, :disco_app_sources, column: :source_id

    DiscoApp::Subscription.where.not(source: nil).find_each do |subscription|
      DiscoApp::Source.find_or_create_by(source: subscription.source) do |new_source|
        new_source.name = subscription.source
      end
    end

    remove_column :disco_app_subscriptions, :source
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
disco_app-0.16.0 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
disco_app-0.16.1 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb