From 6f791401dee8f09115c1c1629092df58f7a68af3 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Fri, 3 Feb 2023 15:42:56 +0100 Subject: [PATCH] Add strong_migrations gem --- Gemfile | 1 + Gemfile.lock | 3 +++ Makefile | 3 +++ Procfile | 4 ++++ app.json | 10 +++++++++ app/controllers/application_controller.rb | 1 + config/initializers/strong_migrations.rb | 26 +++++++++++++++++++++++ 7 files changed, 48 insertions(+) create mode 100644 Procfile create mode 100644 app.json create mode 100644 config/initializers/strong_migrations.rb diff --git a/Gemfile b/Gemfile index 0a9d2f56..3e6ae8af 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,7 @@ gem 'puma', '~> 5.0' gem 'pundit', '~> 2.2' gem 'rails', '7.0.4' gem 'sprockets-rails' +gem 'strong_migrations' gem 'stimulus-rails' gem 'tailwindcss-rails' gem 'turbo-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 0cba0646..e30130fb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -227,6 +227,8 @@ GEM sprockets (>= 3.0.0) stimulus-rails (1.2.1) railties (>= 6.0.0) + strong_migrations (1.4.2) + activerecord (>= 5.2) tailwindcss-rails (2.0.21-aarch64-linux) railties (>= 6.0.0) tailwindcss-rails (2.0.21-arm64-darwin) @@ -268,6 +270,7 @@ DEPENDENCIES simplecov (~> 0.21) sprockets-rails stimulus-rails + strong_migrations tailwindcss-rails turbo-rails tzinfo-data diff --git a/Makefile b/Makefile index 6129e6aa..b8b3ff53 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,9 @@ start_sidekiq: start: docker-compose up -d solo_customer_template_app make debug + +overmind: + overmind start -f Procfile.dev # Running the project test: diff --git a/Procfile b/Procfile new file mode 100644 index 00000000..2ec522c6 --- /dev/null +++ b/Procfile @@ -0,0 +1,4 @@ +web: bundle exec puma -C config/puma.rb +worker: bundle exec sidekiq -C config/sidekiq.yml + +release: bundle exec rails db:migrate diff --git a/app.json b/app.json new file mode 100644 index 00000000..268a27a4 --- /dev/null +++ b/app.json @@ -0,0 +1,10 @@ +{ + "formation": { + "web": { + "quantity": 1 + }, + "worker": { + "quantity": 1 + } + } +} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d12..cfb0a0a5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,3 @@ class ApplicationController < ActionController::Base + include Pundit::Authorization end diff --git a/config/initializers/strong_migrations.rb b/config/initializers/strong_migrations.rb new file mode 100644 index 00000000..adc19cda --- /dev/null +++ b/config/initializers/strong_migrations.rb @@ -0,0 +1,26 @@ +# Mark existing migrations as safe +StrongMigrations.start_after = 20230203144254 + +# Set timeouts for migrations +# If you use PgBouncer in transaction mode, delete these lines and set timeouts on the database user +StrongMigrations.lock_timeout = 10.seconds +StrongMigrations.statement_timeout = 1.hour + +# Analyze tables after indexes are added +# Outdated statistics can sometimes hurt performance +StrongMigrations.auto_analyze = true + +# Set the version of the production database +# so the right checks are run in development +# StrongMigrations.target_version = 10 + +# Add custom checks +# StrongMigrations.add_check do |method, args| +# if method == :add_index && args[0].to_s == "users" +# stop! "No more indexes on the users table" +# end +# end + +# Make some operations safe by default +# See https://github.com/ankane/strong_migrations#safe-by-default +# StrongMigrations.safe_by_default = true