Sha256: c1216bda6dbd5bb5c1a587ac37f8e0a7f81c28ec4ea2f8f0515ef8088424ab3e

Contents?: true

Size: 537 Bytes

Versions: 10

Compression:

Stored size: 537 Bytes

Contents

class AddSourcesToShopSubscriptions < ActiveRecord::Migration
  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

10 entries across 10 versions & 1 rubygems

Version Path
disco_app-0.13.0 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
disco_app-0.13.1 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
disco_app-0.13.2 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
disco_app-0.13.3 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
disco_app-0.13.4 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
disco_app-0.13.5 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
disco_app-0.13.6 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
disco_app-0.13.7 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
disco_app-0.13.8 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
disco_app-0.13.6.pre.puma.pre.3 db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb