<commit_before>class MigrateVariantUnitValues < ActiveRecord::Migration
  def up
    Spree::Variant.all.select { |v|
      v.unit_value.nil? && v.product&.variant_unit == "items"
    }.each do |variant|
      variant.unit_value = 1
      variant.save
    end
  end

  def down
  end
end<commit_msg>use more efficient query; enforce not null at db level<commit_after>class MigrateVariantUnitValues < ActiveRecord::Migration
  def up
    Spree::Variant.includes(:product).where(
      spree_products: { variant_unit: "items" },
      spree_variants: { unit_value: nil }
    ).each do |variant|
      variant.unit_value = 1
      variant.save
    end
    change_column_null :spree_variants, :unit_value, false, 1
  end

  def down
  end
end
{'fraction_non_alphanumeric': 0.09497964721845319, 'fraction_numerical': 0.004070556309362279, 'mean_word_length': 3.2906976744186047, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2010704', 'n_tokens_mistral': 242, 'n_tokens_neox': 235, 'n_words': 59}