From fdba424d77ef3d835f89d37f3f04840fbc2c839f Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Fri, 23 Oct 2020 00:13:38 +0000 Subject: Use match? instead of =~ when MatchData is not used (#34150). Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@20168 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- db/migrate/20120422150750_change_repositories_to_full_sti.rb | 2 +- db/migrate/20180923082945_change_sqlite_booleans_to_0_and_1.rb | 4 ++-- db/migrate/20180923091603_change_sqlite_booleans_default.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'db') diff --git a/db/migrate/20120422150750_change_repositories_to_full_sti.rb b/db/migrate/20120422150750_change_repositories_to_full_sti.rb index 101ecbc12..f97d47cf1 100644 --- a/db/migrate/20120422150750_change_repositories_to_full_sti.rb +++ b/db/migrate/20120422150750_change_repositories_to_full_sti.rb @@ -3,7 +3,7 @@ class ChangeRepositoriesToFullSti < ActiveRecord::Migration[4.2] Repository.connection. select_rows("SELECT id, type FROM #{Repository.table_name}"). each do |repository_id, repository_type| - unless repository_type =~ /^Repository::/ + unless /^Repository::/.match?(repository_type) Repository.where(["id = ?", repository_id]). update_all(["type = ?", "Repository::#{repository_type}"]) end diff --git a/db/migrate/20180923082945_change_sqlite_booleans_to_0_and_1.rb b/db/migrate/20180923082945_change_sqlite_booleans_to_0_and_1.rb index fb789ae10..769ea7a51 100644 --- a/db/migrate/20180923082945_change_sqlite_booleans_to_0_and_1.rb +++ b/db/migrate/20180923082945_change_sqlite_booleans_to_0_and_1.rb @@ -23,7 +23,7 @@ class ChangeSqliteBooleansTo0And1 < ActiveRecord::Migration[5.2] } def up - if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i + if /sqlite/i.match?(ActiveRecord::Base.connection.adapter_name) COLUMNS.each do |klass, columns| columns.each do |column| klass.where("#{column} = 't'").update_all(column => 1) @@ -34,7 +34,7 @@ class ChangeSqliteBooleansTo0And1 < ActiveRecord::Migration[5.2] end def down - if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i + if /sqlite/i.match?(ActiveRecord::Base.connection.adapter_name) COLUMNS.each do |klass, columns| columns.each do |column| klass.where("#{column} = 1").update_all(column => 't') diff --git a/db/migrate/20180923091603_change_sqlite_booleans_default.rb b/db/migrate/20180923091603_change_sqlite_booleans_default.rb index 563bf3237..e72917b12 100644 --- a/db/migrate/20180923091603_change_sqlite_booleans_default.rb +++ b/db/migrate/20180923091603_change_sqlite_booleans_default.rb @@ -74,7 +74,7 @@ class ChangeSqliteBooleansDefault < ActiveRecord::Migration[5.2] } def up - if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i + if /sqlite/i.match?(ActiveRecord::Base.connection.adapter_name) DEFAULTS.each do |table, defaults| defaults.each do |column, value| # Reset default values for boolean column (t/f => 1/0) @@ -85,7 +85,7 @@ class ChangeSqliteBooleansDefault < ActiveRecord::Migration[5.2] end def down - if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i + if /sqlite/i.match?(ActiveRecord::Base.connection.adapter_name) # Cannot restore default values as t/f raise ActiveRecord::IrreversibleMigration end -- cgit v1.2.3