impress/db/migrate/20240227231815_add_series_name_to_alt_styles.rb
Emi Matchu 9f74e6020e Add series_name database field to alt styles
Previously we did this hackily by comparing the ID to a hardcoded list
of IDs, but I think putting this in the database is clearer and more
robust, and it should also help with our upcoming item search stuff
that will filter by it!
2024-02-27 15:28:05 -08:00

18 lines
695 B
Ruby

class AddSeriesNameToAltStyles < ActiveRecord::Migration[7.1]
def change
add_column :alt_styles, :series_name, :string, null: false,
default: "<New?>"
reversible do |direction|
direction.up do
# These IDs are determined by Neopets.com, so referencing them like
# this should be relatively stable! Backfill the series name
# "Nostalgic" for all alt styles in the Nostalgic ID range. (At time
# of writing, *all* alt styles are Nostalgic, but I'm writing it like
# this for clarity and future-proofing!)
AltStyle.where("id >= 87249 AND id <= 87503").update_all(
series_name: "Nostalgic")
end
end
end
end