<commit_before>class CreateSectionFilters < ActiveRecord::Migration
  class Offer < ActiveRecord::Base
    has_and_belongs_to_many :filters
    has_and_belongs_to_many :section_filters,
                            association_foreign_key: 'filter_id',
                            join_table: 'filters_offers'

    belongs_to :section_filter
  end

  class SectionFilter < ActiveRecord::Base
  end

  def up
    create_table :section_filters do |t|
      t.string :name
      t.string :identifier

      t.timestamps null: false
    end

    add_column :offers, :section_filter_id, :integer

    SectionFilter.create(name: 'Family', identifier: 'family')
    SectionFilter.create(name: 'Refugees', identifier: 'refugees')

    Offer.find_each do |offer|
      new_section =
        SectionFilter.find_by_identifier offer.section_filters.first.identifier
      offer.section_filter_id = new_section.id
    end
  end

  def down
    drop_table :section_filters
    remove_column :offers, :section_filter_id
  end
end<commit_msg>update failing migration<commit_after>class CreateSectionFilters < ActiveRecord::Migration
  class Offer < ActiveRecord::Base
    has_and_belongs_to_many :filters
    has_and_belongs_to_many :section_filters,
                            association_foreign_key: 'filter_id',
                            join_table: 'filters_offers'

    belongs_to :section_filter
  end

  class SectionFilter < ActiveRecord::Base
  end

  def up
    create_table :section_filters do |t|
      t.string :name
      t.string :identifier

      t.timestamps null: false
    end

    add_column :offers, :section_filter_id, :integer

    fam_new_id = SectionFilter.create(name: 'Family', identifier: 'family').id
    ref_new_id = SectionFilter.create(name: 'Refugees', identifier: 'refugees').id

    Offer.find_each do |offer|
      new_id = offer.filter_ids.include?(76) ? fam_new_id : ref_new_id
      offer.section_filter_id = new_id
    end
  end

  def down
    drop_table :section_filters
    remove_column :offers, :section_filter_id
  end
end
{'fraction_non_alphanumeric': 0.07295719844357977, 'fraction_numerical': 0.0009727626459143969, 'mean_word_length': 3.1388329979879277, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2646178', 'n_tokens_mistral': 641, 'n_tokens_neox': 627, 'n_words': 136}