class EnableYoutubeOnPremiumLightPlan < ActiveRecord::Migration[7.2]
  def up
    plan = Plan.find_by(slug: "premium_light")
    return unless plan

    features = plan.features.deep_dup
    platforms = Array(features["platforms"]).map(&:to_s)
    features["platforms"] = (platforms + ["youtube"]).uniq
    plan.update!(features: features)
  end

  def down
    plan = Plan.find_by(slug: "premium_light")
    return unless plan

    features = plan.features.deep_dup
    features["platforms"] = Array(features["platforms"]).map(&:to_s) - ["youtube"]
    plan.update!(features: features)
  end
end
