From 303214475a82ac4ff2263e4ca693aa56f18e3a73 Mon Sep 17 00:00:00 2001 From: Zeke Gabrielse Date: Mon, 9 Sep 2024 08:19:34 -0500 Subject: [PATCH] extract verbose_migrations gem --- Gemfile | 1 + Gemfile.lock | 3 +++ config/initializers/verbose_migrations.rb | 3 --- lib/verbose_migrations.rb | 28 ----------------------- 4 files changed, 4 insertions(+), 31 deletions(-) delete mode 100644 config/initializers/verbose_migrations.rb delete mode 100644 lib/verbose_migrations.rb diff --git a/Gemfile b/Gemfile index 7e64ac5a6a..15fc18d0f2 100644 --- a/Gemfile +++ b/Gemfile @@ -20,6 +20,7 @@ gem 'redis', '~> 4.7.1' # API migrations gem 'request_migrations', '~> 1.1' +gem 'verbose_migrations' # API params gem 'typed_params', '~> 1.2.5' diff --git a/Gemfile.lock b/Gemfile.lock index ebae0cf271..e86da498ad 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -492,6 +492,8 @@ GEM concurrent-ruby (~> 1.0) uniform_notifier (1.16.0) uri (0.12.2) + verbose_migrations (1.0.1) + rails (>= 6.0) webmock (3.14.0) addressable (>= 2.8.0) crack (>= 0.3.2) @@ -578,6 +580,7 @@ DEPENDENCIES tracer typed_params (~> 1.2.5) uri (>= 0.12.2) + verbose_migrations webmock (~> 3.14.0) RUBY VERSION diff --git a/config/initializers/verbose_migrations.rb b/config/initializers/verbose_migrations.rb deleted file mode 100644 index cb6eaab1cd..0000000000 --- a/config/initializers/verbose_migrations.rb +++ /dev/null @@ -1,3 +0,0 @@ -# frozen_string_literal: true - -require_dependency Rails.root / 'lib' / 'verbose_migrations' diff --git a/lib/verbose_migrations.rb b/lib/verbose_migrations.rb deleted file mode 100644 index 0fc8e7a573..0000000000 --- a/lib/verbose_migrations.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -require 'logger' - -module VerboseMigrations - module MigrationExtension - cattr_accessor :verbose_logger, default: nil - cattr_accessor :verbosity, default: nil - - def verbose? = verbosity.present? && verbose_logger.present? - def verbose!(logger: ActiveRecord::Base.logger, level: Logger::DEBUG) - self.verbose_logger = logger - self.verbosity = level - end - - def migrate(...) - verbosity_was, verbose_logger.level = verbose_logger.level, verbosity if verbose? - - super - ensure - verbose_logger.level = verbosity_was if verbose? - end - end - - ActiveSupport.on_load :active_record do - ActiveRecord::Migration.prepend(MigrationExtension) - end -end