Migrations
- Adds series of migrations for changing the weapon's series to the values used by Cygames - Shuffled around some foreign keys
This commit is contained in:
parent
38f40d9269
commit
487c01bd07
8 changed files with 204 additions and 4 deletions
134
db/data/20250218023335_migrate_weapon_series.rb
Normal file
134
db/data/20250218023335_migrate_weapon_series.rb
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class MigrateWeaponSeries < ActiveRecord::Migration[8.0]
|
||||||
|
def up
|
||||||
|
Weapon.transaction do
|
||||||
|
puts 'Starting weapon series migration...'
|
||||||
|
|
||||||
|
puts 'Updating Seraphic Weapons (0 -> 1)...'
|
||||||
|
Weapon.find_by(series: 0).update!(new_series: 1)
|
||||||
|
|
||||||
|
puts 'Updating Grand Weapons (1 -> 2)...'
|
||||||
|
Weapon.find_by(series: 1).update!(new_series: 2)
|
||||||
|
|
||||||
|
puts 'Updating Dark Opus Weapons (2 -> 3)...'
|
||||||
|
Weapon.find_by(series: 2).update!(new_series: 3)
|
||||||
|
|
||||||
|
puts 'Updating Revenant Weapons (4 -> 4)...'
|
||||||
|
Weapon.find_by(series: 4).update!(new_series: 4)
|
||||||
|
|
||||||
|
puts 'Updating Primal Weapons (6 -> 5)...'
|
||||||
|
Weapon.find_by(series: 6).update!(new_series: 5)
|
||||||
|
|
||||||
|
puts 'Updating Beast Weapons (5, 7 -> 6)...'
|
||||||
|
Weapon.find_by(series: 5).update!(new_series: 6)
|
||||||
|
Weapon.find_by(series: 7).update!(new_series: 6)
|
||||||
|
|
||||||
|
puts 'Updating Regalia Weapons (8 -> 7)...'
|
||||||
|
Weapon.find_by(series: 8).update!(new_series: 7)
|
||||||
|
|
||||||
|
puts 'Updating Omega Weapons (9 -> 8)...'
|
||||||
|
Weapon.find_by(series: 9).update!(new_series: 8)
|
||||||
|
|
||||||
|
puts 'Updating Olden Primal Weapons (10 -> 9)...'
|
||||||
|
Weapon.find_by(series: 10).update!(new_series: 9)
|
||||||
|
|
||||||
|
puts 'Updating Hollowsky Weapons (12 -> 10)...'
|
||||||
|
Weapon.find_by(series: 12).update!(new_series: 10)
|
||||||
|
|
||||||
|
puts 'Updating Xeno Weapons (13 -> 11)...'
|
||||||
|
Weapon.find_by(series: 13).update!(new_series: 11)
|
||||||
|
|
||||||
|
puts 'Updating Rose Weapons (15 -> 12)...'
|
||||||
|
Weapon.find_by(series: 15).update!(new_series: 12)
|
||||||
|
|
||||||
|
puts 'Updating Ultima Weapons (17 -> 13)...'
|
||||||
|
Weapon.find_by(series: 17).update!(new_series: 13)
|
||||||
|
|
||||||
|
puts 'Updating Bahamut Weapons (16 -> 14)...'
|
||||||
|
Weapon.find_by(series: 16).update!(new_series: 14)
|
||||||
|
|
||||||
|
puts 'Updating Epic Weapons (18 -> 15)...'
|
||||||
|
Weapon.find_by(series: 18).update!(new_series: 15)
|
||||||
|
|
||||||
|
puts 'Updating Cosmos Weapons (20 -> 16)...'
|
||||||
|
Weapon.find_by(series: 20).update!(new_series: 16)
|
||||||
|
|
||||||
|
puts 'Updating Superlative Weapons (22 -> 17)...'
|
||||||
|
Weapon.find_by(series: 22).update!(new_series: 17)
|
||||||
|
|
||||||
|
puts 'Updating Vintage Weapons (23 -> 18)...'
|
||||||
|
Weapon.find_by(series: 23).update!(new_series: 18)
|
||||||
|
|
||||||
|
puts 'Updating Class Champion Weapons (24 -> 19)...'
|
||||||
|
Weapon.find_by(series: 24).update!(new_series: 19)
|
||||||
|
|
||||||
|
puts 'Updating Sephira Weapons (28 -> 23)...'
|
||||||
|
Weapon.find_by(series: 28).update!(new_series: 23)
|
||||||
|
|
||||||
|
puts 'Updating Astral Weapons (14 -> 26)...'
|
||||||
|
Weapon.find_by(series: 14).update!(new_series: 26)
|
||||||
|
|
||||||
|
puts 'Updating Draconic Weapons (3 -> 27)...'
|
||||||
|
Weapon.find_by(series: 3).update!(new_series: 27)
|
||||||
|
|
||||||
|
puts 'Updating Ancestral Weapons (21 -> 29)...'
|
||||||
|
Weapon.find_by(series: 21).update!(new_series: 29)
|
||||||
|
|
||||||
|
puts 'Updating New World Foundation (29 -> 30)...'
|
||||||
|
Weapon.find_by(series: 29).update!(new_series: 30)
|
||||||
|
|
||||||
|
puts 'Updating Ennead Weapons (19 -> 31)...'
|
||||||
|
Weapon.find_by(series: 19).update!(new_series: 31)
|
||||||
|
|
||||||
|
puts 'Updating Militis Weapons (11 -> 32)...'
|
||||||
|
Weapon.find_by(series: 11).update!(new_series: 32)
|
||||||
|
|
||||||
|
puts 'Updating Malice Weapons (26 -> 33)...'
|
||||||
|
Weapon.find_by(series: 26).update!(new_series: 33)
|
||||||
|
|
||||||
|
puts 'Updating Menace Weapons (26 -> 34)...'
|
||||||
|
Weapon.find_by(series: 26).update!(new_series: 34)
|
||||||
|
|
||||||
|
puts 'Updating Illustrious Weapons (31 -> 35)...'
|
||||||
|
Weapon.find_by(series: 31).update!(new_series: 35)
|
||||||
|
|
||||||
|
puts 'Updating Proven Weapons (25 -> 36)...'
|
||||||
|
Weapon.find_by(series: 25).update!(new_series: 36)
|
||||||
|
|
||||||
|
puts 'Updating Revans Weapons (30 -> 37)...'
|
||||||
|
Weapon.find_by(series: 30).update!(new_series: 37)
|
||||||
|
|
||||||
|
puts 'Updating World Weapons (32 -> 38)...'
|
||||||
|
Weapon.find_by(series: 32).update!(new_series: 38)
|
||||||
|
|
||||||
|
puts 'Updating Exo Weapons (33 -> 39)...'
|
||||||
|
Weapon.find_by(series: 33).update!(new_series: 39)
|
||||||
|
|
||||||
|
puts 'Updating Draconic Weapons Providence (34 -> 40)...'
|
||||||
|
Weapon.find_by(series: 34).update!(new_series: 40)
|
||||||
|
|
||||||
|
puts 'Updating Celestial Weapons (37 -> 41)...'
|
||||||
|
Weapon.find_by(series: 37).update!(new_series: 41)
|
||||||
|
|
||||||
|
puts 'Updating Omega Rebirth Weapons (38 -> 42)...'
|
||||||
|
Weapon.find_by(series: 38).update!(new_series: 42)
|
||||||
|
|
||||||
|
puts 'Updating Event Weapons (34 -> 98)...'
|
||||||
|
Weapon.find_by(series: 34).update!(new_series: 98) # Event
|
||||||
|
|
||||||
|
puts 'Updating Gacha Weapons (36 -> 99)...'
|
||||||
|
Weapon.find_by(series: 36).update!(new_series: 99) # Gacha
|
||||||
|
|
||||||
|
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
|
||||||
37
db/data/20250218025755_migrate_series_on_weapon_key.rb
Normal file
37
db/data/20250218025755_migrate_series_on_weapon_key.rb
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
# 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
|
||||||
|
|
@ -1 +1 @@
|
||||||
DataMigrate::Data.define(version: 20250115094623)
|
DataMigrate::Data.define(version: 20250218025755)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
class MakeJobForeignKeyDeferrable < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
remove_foreign_key :jobs, column: :base_job_id
|
||||||
|
add_foreign_key :jobs, :jobs, column: :base_job_id, deferrable: :deferred, initially_deferred: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
class RemoveForeignKeyConstraintOnJobsBaseJobId < ActiveRecord::Migration[8.0]
|
||||||
|
# Removes the self-referential foreign key constraint on jobs.base_job_id.
|
||||||
|
# This constraint was causing issues when seeding job records via CSV.
|
||||||
|
def change
|
||||||
|
# Check if the foreign key exists before removing it
|
||||||
|
if foreign_key_exists?(:jobs, column: :base_job_id)
|
||||||
|
remove_foreign_key :jobs, column: :base_job_id
|
||||||
|
Rails.logger.info 'Removed foreign key constraint on jobs.base_job_id'
|
||||||
|
else
|
||||||
|
Rails.logger.info 'No foreign key on jobs.base_job_id found'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
5
db/migrate/20250218023315_add_new_series_to_weapons.rb
Normal file
5
db/migrate/20250218023315_add_new_series_to_weapons.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddNewSeriesToWeapons < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
add_column :weapons, :new_series, :integer
|
||||||
|
end
|
||||||
|
end
|
||||||
6
db/migrate/20250218025315_move_new_series_to_series.rb
Normal file
6
db/migrate/20250218025315_move_new_series_to_series.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
class MoveNewSeriesToSeries < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
remove_column :weapons, :series
|
||||||
|
rename_column :weapons, :new_series, :series
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2025_02_01_170037) do
|
ActiveRecord::Schema[8.0].define(version: 2025_02_18_025315) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "btree_gin"
|
enable_extension "btree_gin"
|
||||||
enable_extension "pg_catalog.plpgsql"
|
enable_extension "pg_catalog.plpgsql"
|
||||||
|
|
@ -465,7 +465,6 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_01_170037) do
|
||||||
t.integer "rarity"
|
t.integer "rarity"
|
||||||
t.integer "element"
|
t.integer "element"
|
||||||
t.integer "proficiency"
|
t.integer "proficiency"
|
||||||
t.integer "series", default: -1, null: false
|
|
||||||
t.boolean "flb", default: false, null: false
|
t.boolean "flb", default: false, null: false
|
||||||
t.boolean "ulb", default: false, null: false
|
t.boolean "ulb", default: false, null: false
|
||||||
t.integer "max_level", default: 100, null: false
|
t.integer "max_level", default: 100, null: false
|
||||||
|
|
@ -495,6 +494,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_01_170037) do
|
||||||
t.boolean "transcendence", default: false
|
t.boolean "transcendence", default: false
|
||||||
t.date "transcendence_date"
|
t.date "transcendence_date"
|
||||||
t.string "recruits"
|
t.string "recruits"
|
||||||
|
t.integer "series"
|
||||||
t.index ["granblue_id"], name: "index_weapons_on_granblue_id"
|
t.index ["granblue_id"], name: "index_weapons_on_granblue_id"
|
||||||
t.index ["name_en"], name: "index_weapons_on_name_en", opclass: :gin_trgm_ops, using: :gin
|
t.index ["name_en"], name: "index_weapons_on_name_en", opclass: :gin_trgm_ops, using: :gin
|
||||||
t.index ["recruits"], name: "index_weapons_on_recruits"
|
t.index ["recruits"], name: "index_weapons_on_recruits"
|
||||||
|
|
@ -511,7 +511,6 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_01_170037) do
|
||||||
add_foreign_key "grid_weapons", "parties"
|
add_foreign_key "grid_weapons", "parties"
|
||||||
add_foreign_key "grid_weapons", "weapon_keys", column: "weapon_key3_id"
|
add_foreign_key "grid_weapons", "weapon_keys", column: "weapon_key3_id"
|
||||||
add_foreign_key "grid_weapons", "weapons"
|
add_foreign_key "grid_weapons", "weapons"
|
||||||
add_foreign_key "jobs", "jobs", column: "base_job_id"
|
|
||||||
add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id"
|
add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id"
|
||||||
add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id"
|
add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id"
|
||||||
add_foreign_key "parties", "guidebooks", column: "guidebook1_id"
|
add_foreign_key "parties", "guidebooks", column: "guidebook1_id"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue