From ce5e657d114322aef55df60f211059234e9203fb Mon Sep 17 00:00:00 2001 From: Markus Reisner Date: Wed, 4 Oct 2023 13:38:42 +0200 Subject: [PATCH] Refs #36547 - Fix parsing of Ubuntu version in fact parsers --- db/migrate/20230719080900_fix_ubuntu_versions.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 -