diff --git a/db/migrate/20230719080900_fix_ubuntu_versions.rb b/db/migrate/20230719080900_fix_ubuntu_versions.rb index f58a4a32cff..786c0a9680b 100644 --- a/db/migrate/20230719080900_fix_ubuntu_versions.rb +++ b/db/migrate/20230719080900_fix_ubuntu_versions.rb @@ -3,11 +3,10 @@ def up # For every Ubuntu operating system with a set minor version we # * Check if there is already an operating system present with the same major and minor version combined in the major field # * If not, we update the version - Operatingsystem.where('name ~* :name', name: 'ubuntu') - .merge(Operatingsystem.where.not(minor: [nil, ''])).each do |os| - if !Operatingsystem.where('name ~* :name', name: 'ubuntu').merge(Operatingsystem.where(major: "#{os.major}.#{os.minor}")).merge(Operatingsystem.where(minor: [nil, ''])).first + Operatingsystem.where(name: 'Ubuntu').where.not(minor: [nil, '']).each do |os| + unless Operatingsystem.find_by(name: 'Ubuntu', major: "#{os.major}.#{os.minor}", minor: [nil, '']) os.update(major: "#{os.major}.#{os.minor}", minor: nil) end end + end end -