aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorGannon McGibbon <gannon.mcgibbon@gmail.com>2019-03-07 19:54:34 -0500
committerGannon McGibbon <gannon.mcgibbon@gmail.com>2019-03-08 03:14:56 -0500
commitdcbb79d680da7742b235b278866850d5bafb8e0b (patch)
treeec38778c9b6971fe4810546c02e6ecba9e61a645 /railties/lib/rails
parenta62683f3e4326b222b6ad95b8b2dfcc31026d227 (diff)
downloadrails-dcbb79d680da7742b235b278866850d5bafb8e0b.tar.gz
rails-dcbb79d680da7742b235b278866850d5bafb8e0b.tar.bz2
rails-dcbb79d680da7742b235b278866850d5bafb8e0b.zip
Add version awareness to rails db:system:change
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/generators/rails/db/system/change/change_generator.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/railties/lib/rails/generators/rails/db/system/change/change_generator.rb b/railties/lib/rails/generators/rails/db/system/change/change_generator.rb
index 63849eb18d..24db92fad7 100644
--- a/railties/lib/rails/generators/rails/db/system/change/change_generator.rb
+++ b/railties/lib/rails/generators/rails/db/system/change/change_generator.rb
@@ -35,8 +35,9 @@ module Rails
end
def edit_gemfile
- database_gem_name, _ = gem_for_database
- gsub_file("Gemfile", all_database_gems_regex, database_gem_name)
+ name, version = gem_for_database
+ gsub_file("Gemfile", all_database_gems_regex, name)
+ gsub_file("Gemfile", gem_entry_regex_for(name), gem_entry_for(name, *version))
end
private
@@ -48,6 +49,15 @@ module Rails
all_database_gem_names = all_database_gems.map(&:first)
/(\b#{all_database_gem_names.join('\b|\b')}\b)/
end
+
+ def gem_entry_regex_for(gem_name)
+ /^gem.*\b#{gem_name}\b.*/
+ end
+
+ def gem_entry_for(*gem_name_and_version)
+ gem_name_and_version.map! { |segment| "'#{segment}'" }
+ "gem #{gem_name_and_version.join(", ")}"
+ end
end
end
end