migration_queries 0.3.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 356aa56fbb9c867de2ff9a1ec41c1d4305031f65ba10e8ea50ea523b70896046
4
- data.tar.gz: ec60f761a3f8a81aa4247ff3b4305843cde952951780e5a2c99cbc15b2b8c46a
3
+ metadata.gz: d841a636d5ad72e9991f1f87ed98bb4a0a1b51098a674db5dae93f5d2f94ccaa
4
+ data.tar.gz: aa79169e44d9ce5adbbf1142d738d49b3aee19048f86baa82be747695b653c8a
5
5
  SHA512:
6
- metadata.gz: d2572cb64efab92fcda737c55dda35c7cc1ce8b0786f23435538335d45dc5631663a89f1fba5f2a49b6d20b647ecfff6190309d04750f775bbd6a0d4ec2adb05
7
- data.tar.gz: da96b269d7049e01c2289a8cbaae3ca7789eb78961bbb0fd6d3d233577d038ebb862545c7cf6b7dfd9d8b58fa1a07e4c78bf2cc51ad2dca3676a28fe663297de
6
+ metadata.gz: 65e15bb1a441237afbc72d50a9206334dd7dafee4e0f4af3cbbbb949106e3e3e57088bada8464b781071177219ca366f1ffb1e34b3ef30675ce8117a09d59a27
7
+ data.tar.gz: b0cecb473508ad96399022335b6ff0e9decc6951f6f7f6b82f6bdd45a7acd70733a16358a8906f4279a93d8697ba8e9240bef4f0e77798a39d8845ac640ff29c
data/README.md CHANGED
@@ -1,28 +1,40 @@
1
1
  # MigrationQueries
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
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/migration_queries`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ The `migration_queries` gem improves tracking of migration queries in Ruby on Rails applications. It provides a simple way to log and analyze the SQL queries generated by ActiveRecord migrations, helping developers optimize their database interactions.
6
4
 
7
5
  ## Installation
8
6
 
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.
10
-
11
- Install the gem and add to the application's Gemfile by executing:
7
+ Add this gem to development dependencies in your `Gemfile`:
12
8
 
13
- ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
9
+ ```ruby
10
+ group :development do
11
+ gem 'migration_queries'
12
+ end
15
13
  ```
16
14
 
17
- If bundler is not being used to manage dependencies, install the gem by executing:
18
-
19
- ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
- ```
15
+ Then, run `bundle install` to install the gem.
22
16
 
23
17
  ## Usage
24
18
 
25
- TODO: Write usage instructions here
19
+ The gem is going to automatically track migration queries executed by ActiveRecord. You can view the logged queries in your Rails console or in the log files.
20
+
21
+ Example migration file after running migration and logging queries:
22
+
23
+ ```ruby
24
+ class AddExampleTable < ActiveRecord::Migration[6.0]
25
+ def change
26
+ create_table :example do |t|
27
+ t.string :name
28
+ t.timestamps
29
+ end
30
+ end
31
+ end
32
+ =begin Migration Queries
33
+ CREATE TABLE "example" ("id" bigserial primary key, "name" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
34
+
35
+ # Migration Queries written on 2025-07-04 12:36:54 +0200
36
+ =end
37
+ ```
26
38
 
27
39
  ## Development
28
40
 
data/Rakefile CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- load("lib/tasks/setup_migration_queries.rake")
4
-
5
3
  require "bundler/gem_tasks"
6
4
  require "rspec/core/rake_task"
7
5
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MigrationQueries
4
- VERSION = "0.3.0"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -6,6 +6,9 @@ require_relative "migration_queries/executer"
6
6
  require_relative "migration_queries/migrater"
7
7
  require "active_record"
8
8
 
9
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.include(MigrationQueries::Executer)
10
+ ActiveRecord::Migration::Current.include(MigrationQueries::Migrater)
11
+
9
12
  # MigrationQueries is a module that provides functionality to gather, execute, and migrate SQL queries
10
13
  # during ActiveRecord migrations. It includes the Gatherer, Executer, and Migrater modules to handle
11
14
  # different aspects of SQL query management.
@@ -15,9 +18,4 @@ module MigrationQueries
15
18
  def self.gatherer
16
19
  @gatherer ||= MigrationQueries::Gatherer.new
17
20
  end
18
-
19
- def self.init!
20
- ActiveRecord::ConnectionAdapters::AbstractAdapter.include(MigrationQueries::Executer)
21
- ActiveRecord::Migration::Current.include(MigrationQueries::Migrater)
22
- end
23
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: migration_queries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Szymon Lipka
@@ -46,7 +46,6 @@ files:
46
46
  - lib/migration_queries/gatherer.rb
47
47
  - lib/migration_queries/migrater.rb
48
48
  - lib/migration_queries/version.rb
49
- - lib/tasks/setup_migration_queries.rake
50
49
  - sig/migration_queries.rbs
51
50
  - sig/migration_queries/data.rbs
52
51
  - sig/migration_queries/executer.rbs
@@ -1,24 +0,0 @@
1
- # lib/tasks/setup_migration_queries.rake
2
-
3
- namespace :migration_queries do
4
- desc "Create migration_queries.rb initializer"
5
- task :setup do
6
- initializer_path = Rails.root.join("config", "initializers", "migration_queries.rb")
7
- content = <<~RUBY
8
- # frozen_string_literal: true
9
-
10
- if Rails.env.development?
11
- require 'migration_queries'
12
-
13
- MigrationQueries.init!
14
- end
15
- RUBY
16
-
17
- if File.exist?(initializer_path)
18
- puts "Initializer file already exists at #{initializer_path}"
19
- else
20
- File.write(initializer_path, content)
21
- puts "Created initializer file at #{initializer_path}"
22
- end
23
- end
24
- end