Skip to content

Commit 1f1165e

Browse files
authored
Rename categories to change Covid- prefix to sfsg-. (#755)
These were originally named during the beginning of the COVID-19 pandemic, but since then, they've taken on a more general purpose that is specific to the SFSG site, as opposed to the other white-labeled sites. Running this migration also needs to be followed up with reindexing the Algolia, and this will also require some coordinated changes on the frontend app.
1 parent e31edb0 commit 1f1165e

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class RenameCategoryCovidPrefixToSfsg < ActiveRecord::Migration[6.1]
2+
def up
3+
ActiveRecord::Base.transaction do
4+
select_all("SELECT id, name FROM categories WHERE name LIKE 'Covid-%'", "get Covid categories").each do |row|
5+
old = row["name"]
6+
new = row["name"].gsub("Covid-", "sfsg-")
7+
exec_query("UPDATE categories SET name = $1 WHERE name = $2", "rename #{old} to #{new}", [new, old])
8+
end
9+
end
10+
end
11+
12+
def down
13+
raise ActiveRecord::IrreversibleMigration
14+
end
15+
end

db/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2025_01_30_044205) do
13+
ActiveRecord::Schema.define(version: 2025_02_26_165117) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"

0 commit comments

Comments
 (0)