Skip to content

Commit d5b80e7

Browse files
committed
Change migration to be reversible if needed
1 parent c84d839 commit d5b80e7

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class UpdateCreatorIdIndexOnSchools < ActiveRecord::Migration[7.2]
2-
def change
2+
def up
33
remove_index :schools, name: "index_schools_on_creator_id"
44

55
add_index :schools,
@@ -8,4 +8,13 @@ def change
88
where: "rejected_at IS NULL",
99
name: "index_schools_on_creator_id_active_only"
1010
end
11-
end
11+
12+
def down
13+
remove_index :schools, name: "index_schools_on_creator_id_active_only"
14+
15+
add_index :schools,
16+
:creator_id,
17+
unique: true,
18+
name: "index_schools_on_creator_id"
19+
end
20+
end

0 commit comments

Comments
 (0)