<commit_before>class MoveOfferLocationToTableLocations < ActiveRecord::Migration[5.0]
  def up
    execute(%q{INSERT INTO locations (country_id, province_id, city, created_at, updated_at) SELECT country_id, province_id, location, NOW(), NOW() FROM offers})
    add_column :offers, :location_id, :integer
    execute(%q{UPDATE offers AS o SET location_id = l.id FROM locations AS l WHERE o.country_id = l.country_id AND (o.province_id = l.province_id OR (o.province_id IS NULL AND l.province_id IS NULL)) AND o.location = l.city})
    remove_column :offers, :location
    remove_column :offers, :province_id
    remove_column :offers, :country_id
    add_foreign_key :offers, :locations
  end

  def down
    add_column :offers, :location, :string<commit_msg>Patch migration moving offer location to locations table<commit_after>class MoveOfferLocationToTableLocations < ActiveRecord::Migration[5.0]
  def up
    execute(%q{INSERT INTO locations (country_id, province_id, city, created_at, updated_at) SELECT country_id, province_id, location, NOW(), NOW() FROM offers})
    add_column :offers, :location_id, :integer
    execute(%q{UPDATE offers AS o SET location_id = l.id FROM locations AS l WHERE o.country_id = l.country_id AND (o.province_id = l.province_id OR (o.province_id IS NULL AND l.province_id IS NULL)) AND (o.location = l.city OR (o.location IS NULL AND l.city IS NULL))})
    remove_column :offers, :location
    remove_column :offers, :province_id
    remove_column :offers, :country_id
    add_foreign_key :offers, :locations
  end

  def down
    add_column :offers, :location, :string
{'fraction_non_alphanumeric': 0.09351620947630923, 'fraction_numerical': 0.0024937655860349127, 'mean_word_length': 4.9888059701492535, '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': '5012513', 'n_tokens_mistral': 523, 'n_tokens_neox': 510, 'n_words': 158}