Sha256: 93ca2a2e0121d2f1c23fc87f3c9b2ffa29e025b3dd901dc6b8d9431e3fcad315

Contents?: true

Size: 977 Bytes

Versions: 94

Compression:

Stored size: 977 Bytes

Contents

class AddProductToFeedbackResources < ActiveRecord::Migration[5.1]
  def up
    add_column :feedback_resources, :product, :string
    add_index :feedback_resources, :product

    products = [
      'voice/sip',
      'voice/voice-api',
      'messaging/sms',
      'messaging/conversion-api',
      'messaging/sns',
      'messaging/us-short-codes',
      'verify',
      'number-insight',
      'account',
      'concepts',
      'stitch/in-app-voice',
      'stitch/in-app-messaging',
      'messages-and-workflows-apis/messages',
      'messages-and-workflows-apis/workflows',
    ]

    Feedback::Resource.all.each do |feedback_resource|
      uri = URI(feedback_resource.uri)

      product = products.detect do |product|
        break product if uri.path.start_with? "/#{product}"
      end

      next unless product

      feedback_resource.update({
        product: product,
      })
    end
  end

  def down
    remove_column :feedback_resources, :product
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
station-0.5.16 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.15 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.14 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.13 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.12 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.11 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.10 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.9 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.8 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.7 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.6 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.5 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.4 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.3 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.2 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.1 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.5.0 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.4.9 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.4.8 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb
station-0.4.7 lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb