Sha256: f0e14a13a001e7ad2ff2abdfd065ccb54f75126a9249420037dd4bb23b18153d

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

class ChangeStripeSubscriptionSchedulePhaseIdToBigint < ActiveRecord::Migration[6.0]
  def change
    if postgres?
      change_column( # rubocop:disable Rails/ReversibleMigration
        :stripe_subscription_schedule_phase_plans,
        :stripe_subscription_schedule_phase_id,
        "bigint USING stripe_subscription_schedule_phase_id::bigint"
      )
    elsif mysql?
      change_column( # rubocop:disable Rails/ReversibleMigration
        :stripe_subscription_schedule_phase_plans,
        :stripe_subscription_schedule_phase_id,
        "bigint USING CAST(stripe_subscription_schedule_phase_id AS bigint"
      )
    else
      change_column :stripe_subscription_schedule_phase_plans, :stripe_subscription_schedule_phase_id, :bigint # rubocop:disable Rails/ReversibleMigration
    end
  end

  def mysql?
    ActiveRecord::Base.connection.adapter_name.downcase.include?("mysql")
  end

  def postgres?
    %w[PostGIS Postgres].include?(ActiveRecord::Base.connection.adapter_name)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stripe_model_callbacks-0.1.5 db/migrate/20200520152604_change_stripe_subscription_schedule_phase_id_to_bigint.rb