verbose_migrations 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad7f17b9ff82b8e574b88002acbf340b8195a4aa34a50729bd836c2dde8fc1d8
4
- data.tar.gz: 558746287b7911ae80562b1a2408ca15bfbe46fbe8533bd9d8abef259790c82e
3
+ metadata.gz: 7d2c1d35a9c0ebcba2ea106766e8ed501397b3c24941c5f54c74ca028bdfa776
4
+ data.tar.gz: 03ea6cc33ac78bbffc2b69c0908abe59798227dcb237a97705a957e859485e93
5
5
  SHA512:
6
- metadata.gz: fcedca9580af8e1e09cc40baeb63957a6441711f3e443b06de46d5c126c0cc9e39361b7a08a2b7fe8fc65a63931f73cb510b225c3255df97f7d902f4d41f0deb
7
- data.tar.gz: d386a64316f74ddee8596a21775db48a027e8254c9eae606b8942f71c83f218ce3a7e2aea31d97a2fe3ad22f1bd19a3264e9ffc308033679b68b89f510483c5c
6
+ metadata.gz: 386bc10f3b9baba1a5468fc825105900223970127c6a62991fda5431cb588c614d5569dd5d78752bebe655848ee53687fd038f05b9b3feda891d4dde1bc5c436
7
+ data.tar.gz: f293b5b9faf86c3965cf0487144d53a54a533ca2921a740977a23aed44a66065895f4f134ff670594e493d3a536699b2d0c7319125a83bf3576c22e9bdcc8666
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
1
  # Changelog
2
2
 
3
3
  ## [Unreleased]
4
+
5
+ ## v1.0.0
6
+
7
+ Initial release.
data/README.md CHANGED
@@ -1,31 +1,71 @@
1
- # VerboseMigrations
1
+ # verbose_migrations
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ [![CI](https://github.com/keygen-sh/verbose_migrations/actions/workflows/test.yml/badge.svg)](https://github.com/keygen-sh/verbose_migrations/actions)
4
+ [![Gem Version](https://badge.fury.io/rb/verbose_migrations.svg)](https://badge.fury.io/rb/verbose_migrations)
4
5
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/verbose_migrations`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+ Enable verbose logging for Active Record migrations, regardless of configured
7
+ log level. Monitor query speed, query execution, and overall progress when
8
+ executing long running or otherwise risky migrations.
9
+
10
+ This gem was extracted from [Keygen](https://keygen.sh).
11
+
12
+ Sponsored by:
13
+
14
+ <a href="https://keygen.sh?ref=verbose_migrations">
15
+ <div>
16
+ <img src="https://keygen.sh/images/logo-pill.png" width="200" alt="Keygen">
17
+ </div>
18
+ </a>
19
+
20
+ _A fair source software licensing and distribution API._
6
21
 
7
22
  ## Installation
8
23
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
24
+ Add this line to your application's `Gemfile`:
25
+
26
+ ```ruby
27
+ gem 'verbose_migrations'
28
+ ```
10
29
 
11
- Install the gem and add to the application's Gemfile by executing:
30
+ And then execute:
12
31
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
32
+ ```bash
33
+ $ bundle
34
+ ```
14
35
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
36
+ Or install it yourself as:
16
37
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
38
+ ```bash
39
+ $ gem install verbose_migrations
40
+ ```
18
41
 
19
42
  ## Usage
20
43
 
21
- TODO: Write usage instructions here
44
+ ```ruby
45
+ class SeedTagsFromPosts < ActiveRecord::Migration[7.1]
46
+ verbose!
22
47
 
23
- ## Development
48
+ def up
49
+ # ...
50
+ end
51
+ end
52
+ ```
24
53
 
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
54
+ ## Supported Rubies
26
55
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
56
+ **`verbose_migrations` supports Ruby 3.1 and above.** We encourage you to upgrade
57
+ if you're on an older version. Ruby 3 provides a lot of great features, like
58
+ better pattern matching and a new shorthand hash syntax.
59
+
60
+ ## Is it any good?
61
+
62
+ Yes.
28
63
 
29
64
  ## Contributing
30
65
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/verbose_migrations.
66
+ If you have an idea, or have discovered a bug, please open an issue or create a
67
+ pull request.
68
+
69
+ ## License
70
+
71
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VerboseMigrations
4
+ ActiveSupport.on_load :active_record do
5
+ ActiveRecord::Migration.prepend(MigrationExtension)
6
+ end
7
+ end
8
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VerboseMigrations
4
- VERSION = '0.0.1'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -1,6 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support'
4
+ require 'active_record'
5
+ require 'logger'
6
+
3
7
  require_relative 'verbose_migrations/version'
8
+ require_relative 'verbose_migrations/railtie'
4
9
 
5
10
  module VerboseMigrations
11
+ module MigrationExtension
12
+ cattr_accessor :verbose_logger, default: nil
13
+ cattr_accessor :verbosity, default: nil
14
+
15
+ def verbose? = verbosity.present? && verbose_logger.present?
16
+ def verbose!(logger: ActiveRecord::Base.logger, level: Logger::DEBUG)
17
+ self.verbose_logger = logger
18
+ self.verbosity = level
19
+ end
20
+
21
+ def migrate(...)
22
+ verbosity_was, verbose_logger.level = verbose_logger.level, verbosity if verbose?
23
+
24
+ super
25
+ ensure
26
+ verbose_logger.level = verbosity_was if verbose?
27
+ end
28
+ end
6
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verbose_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zeke Gabrielse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-20 00:00:00.000000000 Z
11
+ date: 2024-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,9 +38,51 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: Override Active Record logger to DEBUG mode during Active Record migrations
42
- to easily follow along and spot blocking queries in a migration, even when the logger
43
- is set to e.g. WARN.
41
+ - !ruby/object:Gem::Dependency
42
+ name: transition_through
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: prism
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Enable verbose logging for Active Record migrations, regardless of configured
84
+ log level. Monitor query speed, query execution, and overall progress when executing
85
+ long running or otherwise risky migrations.
44
86
  email:
45
87
  - oss@keygen.sh
46
88
  executables: []
@@ -53,6 +95,7 @@ files:
53
95
  - README.md
54
96
  - SECURITY.md
55
97
  - lib/verbose_migrations.rb
98
+ - lib/verbose_migrations/railtie.rb
56
99
  - lib/verbose_migrations/version.rb
57
100
  homepage: https://github.com/keygen-sh/verbose_migrations
58
101
  licenses:
@@ -76,5 +119,6 @@ requirements: []
76
119
  rubygems_version: 3.4.13
77
120
  signing_key:
78
121
  specification_version: 4
79
- summary: Set Active Record logger to DEBUG mode during Active Record migrations.
122
+ summary: Enable verbose logging for Active Record migrations, regardless of configured
123
+ log level, to monitor query speed and execution.
80
124
  test_files: []