class AddOfficialCharacterNumber < ActiveRecord::Migration[6.0]
  OFFICIAL_NUMBERS = {
    'amphinobi' => '50',
    'banjo-et-kazooie' => '73',
    'bayonetta' => '63',
    'bowser' => '14',
    'bowser-jr' => '58',
    'byleth' => '75',
    'captain-falcon' => '11',
    'chrom' => '25e',
    'cloud' => '61',
    'corrin' => '62',
    'daisy' => '13e',
    'daraen' => '56',
    'diddy-kong' => '36',
    'donkey-kong' => '02',
    'dresseur-pokémon' => '33-35',
    'dr-mario' => '18',
    'duo-duck-hunt' => '59',
    'entraîneuse-wii-fit' => '47',
    'falco' => '20',
    'félinferno' => '69',
    'fox' => '07',
    'ganondorf' => '23',
    'harmonie-et-luma' => '48',
    'héros' => '72',
    'ice-climbers' => '15',
    'ike' => '32',
    'inkling' => '64',
    'joker' => '71',
    'kazuya' => '81',
    'ken' => '60e',
    'king-k-rool' => '67',
    'kirby' => '06',
    'link' => '03',
    'link-cartoon' => '43',
    'link-enfant' => '22',
    'little-mac' => '49',
    'lucario' => '41',
    'lucas' => '37',
    'lucina' => '21e',
    'luigi' => '09',
    'marie' => '68',
    'mario' => '01',
    'marth' => '21',
    'mega-man' => '46',
    'meta-knight' => '27',
    'mewtwo' => '24',
    'mii-boxeur' => '51',
    'mii-épéiste' => '52',
    'mii-tireur' => '53',
    'min-min' => '76',
    'mr-game-&-watch' => '26',
    'ness' => '10',
    'olimar' => '40',
    'pac-man' => '55',
    'palutena' => '54',
    'peach' => '13',
    'pichu' => '19',
    'pikachu' => '08',
    'pit' => '28',
    'pit-maléfique' => '28e',
    'plante-piranha' => '70',
    'pyra/mythra' => '79-80',
    'random' => '99',
    'richter' => '66e',
    'ridley' => '65',
    'rob' => '42',
    'roi-dadidou' => '39',
    'rondoudou' => '12',
    'roy' => '25',
    'ryu' => '60',
    'samus' => '04',
    'samus-sans-armure' => '29',
    'samus-sombre' => '04e',
    'sephiroth' => '78',
    'sheik' => '16',
    'shulk' => '57',
    'simon' => '66',
    'snake' => '31',
    'sonic' => '38',
    'sora' => '82',
    'steve' => '77',
    'terry' => '74',
    'villageois' => '45',
    'wario' => '30',
    'wolf' => '44',
    'yoshi' => '05',
    'zelda' => '17'
  }.freeze

  def change
    add_column :characters, :official_number, :string, null: false, default: ''

    OFFICIAL_NUMBERS.each do |name, official_number|
      Character.where(name: name).update_all(official_number: official_number)
    end

    add_index :characters, :official_number, unique: true
  end
end
