Skip to content

Commit 2c31cef

Browse files
dp4rkDave Parkeoinkelly
authored
Adds strong_migrations gem. Closes #214 (#281)
Have tested this different variants, and all of the existing default migrations pass without errors. --------- Co-authored-by: Dave Park <david.park@ackama.com> Co-authored-by: Eoin Kelly <eoin.kelly@ackama.com>
1 parent 62446f3 commit 2c31cef

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

template.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def apply_template! # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Met
110110
# The block passed to "after_bundle" seems to run after `bundle install`
111111
# but also after `shakapacker:install` and after Rails has initialized the git
112112
# repo
113-
after_bundle do
113+
after_bundle do # rubocop:disable Metrics/BlockLength
114114
# Remove the `test/` directory because we always use RSpec which creates
115115
# its own `spec/` directory
116116
remove_dir "test"
@@ -193,6 +193,13 @@ def apply_template! # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Met
193193
git add: "-A ."
194194
git commit: "-n -m 'Set up erblint'"
195195

196+
# Run strong_migrations generator near the end so that it doesn't block
197+
# other parts of the template from creating migrations.
198+
run_with_clean_bundler_env "bundle exec rails g strong_migrations:install"
199+
run_with_clean_bundler_env "bundle exec rubocop -A -c ./.rubocop.yml"
200+
git add: "-A ."
201+
git commit: "-n -m 'Set up strong_migrations'"
202+
196203
# Run the README template at the end because it introspects the app to
197204
# discover rake tasks etc.
198205
apply_readme_template

variants/backend-base/Gemfile.tt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ gem "stimulus-rails"
3535
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
3636
# gem "image_processing", "~> 1.2"
3737

38+
# Protect against accidentally slow migrations
39+
gem "strong_migrations"
40+
3841
group :development do
3942
gem "letter_opener"
4043

variants/frontend-base/template.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
# Configure app/frontend
2626

2727
run "mv app/javascript app/frontend"
28-
2928
copy_file "config/webpack/webpack.config.js", force: true
3029

3130
gsub_file "config/shakapacker.yml", "source_entry_path: /", "source_entry_path: packs", force: true

0 commit comments

Comments
 (0)