hensei-api/db/data/20250218025755_migrate_series_on_weapon_key.rb
Justin Edmund 3cdd925162
Fix filters and add processors (#181)
* Update test csvs

* Fix count filters and refactor apply_filters

* Update party_querying_concern.rb

* +tests/-debug logs

* Make party association optional in Job

* Updates for weapon series

- Change to new series numbers
- Add static method for querying whether the weapon's element is changeable
- Add a new method to return a text slug for the weapon's series

* Add and update test data

- Updates canonical.rb for loading multiple types of data with multiple types of associations
- Adds test data for Guidebooks, Job Accessories, Job Skills, and Jobs
- Updates test data for Weapons and Summons

* Migrations

- Adds series of migrations for changing the weapon's series to the values used by Cygames
- Shuffled around some foreign keys

* Implement BaseProcessor

Processors are in charge of processing deck data straight from Granblue.

* Implement CharacterProcessor

Process character data from deck

* Implement WeaponProcessor

Process weapon data from deck

* Implement JobProcessor

Process job, job skill, and job accessory data from deck

* Implement SummonProcessor

Process summon data from deck

* Update SummonProcessor to work like the others

* ImportController should use processors

* Process element for changeable weapons
2025-02-17 23:51:50 -08:00

37 lines
1.3 KiB
Ruby

# frozen_string_literal: true
class MigrateSeriesOnWeaponKey < ActiveRecord::Migration[8.0]
def up
WeaponKey.transaction do
puts 'Starting weapon key series migration...'
puts 'Updating Telumas (3 -> 27)...'
WeaponKey.where('? = ANY(series)', 3).update_all('series = array_replace(series, 3, 27)')
puts 'Updating Providence Telumas (34 -> 40)...'
WeaponKey.where('? = ANY(series)', 34).update_all('series = array_replace(series, 34, 40)')
puts 'Updating Gauph Keys (17 -> 13)...'
WeaponKey.where('? = ANY(series)', 17).update_all('series = array_replace(series, 17, 13)')
puts 'Updating Pendulums (2 -> 3)...'
WeaponKey.where('? = ANY(series)', 2).update_all('series = array_replace(series, 2, 3)')
puts 'Updating Chains (2 -> 3)...'
WeaponKey.where('? = ANY(series)', 2).update_all('series = array_replace(series, 2, 3)')
puts 'Updating Emblems (24 -> 19)...'
WeaponKey.where('? = ANY(series)', 24).update_all('series = array_replace(series, 24, 19)')
puts 'Migration completed successfully!'
rescue StandardError => e
puts "Error occurred during migration: #{e.message}"
puts "Backtrace: #{e.backtrace}"
raise e
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end