Skip to content

Commit

Permalink
Update batches only if team exists
Browse files Browse the repository at this point in the history
The reference to `Team.first.id` breaks on an empty database because
there are no teams.
  • Loading branch information
tvararu committed Oct 16, 2024
1 parent eb68186 commit 2b29f0c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion db/migrate/20241015090951_add_team_to_batches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class AddTeamToBatches < ActiveRecord::Migration[7.2]
def up
add_reference :batches, :team, foreign_key: true
Batch.update_all(team_id: Team.first.id)
Batch.update_all(team_id: Team.first.id) if Team.any?
change_column_null :batches, :team_id, false
add_index :batches, %i[team_id name expiry vaccine_id], unique: true
end
Expand Down

0 comments on commit 2b29f0c

Please sign in to comment.