actual_db_schema 0.9.1 → 0.9.2

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: a1fd777a52ad2881a451c80498693f36267944c4fe1c1b6796582900ce968224
4
- data.tar.gz: d051372a40ec8002d72ce969f30cb93f02f09c4cd60b3c151922caa501d21687
3
+ metadata.gz: 026a44cc5c2748387f2d5b62796b6bde8fbed503ab4689bc46e294c8bd2a6fba
4
+ data.tar.gz: faae3b9dcc2f31b5167f2fb6e7fa62f65135ceccd60b0f9dea12f8f7a293049d
5
5
  SHA512:
6
- metadata.gz: b6b16965816aff4dbc9b5cdaa5422a6cb89a609f577d6f5dfc4b93df541067d3d111c1d66decc489a312d4e602460b86e32036ce1c3653fdb477a5075b2fa85c
7
- data.tar.gz: 6c133a90fd82909e1beaac3db9735e98b5d790315a115e190880a428a5cba37b76921549884e947cc67667be5678dd8bc4c9e9bee9fded042be466331651dc2e
6
+ metadata.gz: e38622b499f30c7fc02f8a57c77e59e41412529299cc67c9827b7c52959ee9bd516bc85fc485de6c0abbd818b33c7c4eed14820f41b6a92ba58f339364494cef
7
+ data.tar.gz: 238b844491e2b78d2ff9454e065101647cd5e55bab11101739c19cb77f7c015c1316d511baaa22bfb8d611e5f4cd240c01093b6f5529ec451d612219ab7a14dc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.9.2] - 2026-06-14
2
+
3
+ - Skip pending migrations in the UI
4
+
1
5
  ## [0.9.1] - 2026-02-25
2
6
 
3
7
  - Support schema diffs for `structure.sql`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- actual_db_schema (0.9.1)
4
+ actual_db_schema (0.9.2)
5
5
  activerecord
6
6
  activesupport
7
7
  ast
@@ -10,6 +10,13 @@ module ActualDbSchema
10
10
  app.routes.append do
11
11
  mount ActualDbSchema::Engine => "/rails"
12
12
  end
13
+
14
+ ActiveRecord::Migration::CheckPending.prepend(ActualDbSchema::Patches::CheckPending)
15
+
16
+ app.middleware.insert_before(
17
+ ActiveRecord::Migration::CheckPending,
18
+ ActualDbSchema::Middlewares::SkipPendingMigrationCheck
19
+ )
13
20
  end
14
21
  end
15
22
 
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActualDbSchema
4
+ module Middlewares
5
+ # Middleware that skips the pending migration check for ActualDbSchema UI routes.
6
+ # This allows accessing /rails/ paths even when there are pending migrations.
7
+ class SkipPendingMigrationCheck
8
+ def initialize(app)
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ if actual_db_schema_path?(env["PATH_INFO"], env["REQUEST_METHOD"])
14
+ env["actual_db_schema.skip_pending_check"] = true
15
+ end
16
+ @app.call(env)
17
+ end
18
+
19
+ private
20
+
21
+ def actual_db_schema_path?(path, method)
22
+ return false unless path.start_with?(engine_mount_path)
23
+
24
+ ActualDbSchema::Engine.routes.recognize_path(
25
+ path.sub(engine_mount_path, "") || "/",
26
+ method: method
27
+ )
28
+
29
+ true
30
+ rescue ActionController::RoutingError
31
+ false
32
+ end
33
+
34
+ def engine_mount_path
35
+ @engine_mount_path ||= ActualDbSchema::Engine.routes.find_script_name({})
36
+ end
37
+ end
38
+ end
39
+ end
@@ -6,10 +6,13 @@ module ActualDbSchema
6
6
  include Singleton
7
7
 
8
8
  def each
9
+ original_config = current_config
9
10
  configs.each do |db_config|
10
11
  establish_connection(db_config)
11
12
  yield context
12
13
  end
14
+ ensure
15
+ establish_connection(original_config) if original_config
13
16
  end
14
17
 
15
18
  private
@@ -19,6 +22,14 @@ module ActualDbSchema
19
22
  ActiveRecord::Base.establish_connection(config)
20
23
  end
21
24
 
25
+ def current_config
26
+ if ActiveRecord::Base.respond_to?(:connection_db_config)
27
+ ActiveRecord::Base.connection_db_config
28
+ else
29
+ ActiveRecord::Base.connection_config
30
+ end
31
+ end
32
+
22
33
  def configs
23
34
  all_configs = if ActiveRecord::Base.configurations.is_a?(Hash)
24
35
  # Rails < 6.0 has a Hash in configurations
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActualDbSchema
4
+ module Patches
5
+ # Patches Rails' CheckPending middleware to skip the pending
6
+ # migration check for ActualDbSchema UI routes (/rails/).
7
+ module CheckPending
8
+ def call(env)
9
+ return @app.call(env) if env["actual_db_schema.skip_pending_check"]
10
+
11
+ super
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActualDbSchema
4
- VERSION = "0.9.1"
4
+ VERSION = "0.9.2"
5
5
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "actual_db_schema/middlewares/skip_pending_migration_check"
3
4
  require "actual_db_schema/engine"
4
5
  require "active_record/migration"
5
6
  require "csv"
@@ -14,6 +15,7 @@ require_relative "actual_db_schema/failed_migration"
14
15
  require_relative "actual_db_schema/migration_context"
15
16
  require_relative "actual_db_schema/migration_parser"
16
17
  require_relative "actual_db_schema/output_formatter"
18
+ require_relative "actual_db_schema/patches/check_pending"
17
19
  require_relative "actual_db_schema/patches/migration_proxy"
18
20
  require_relative "actual_db_schema/patches/migrator"
19
21
  require_relative "actual_db_schema/patches/migration_context"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actual_db_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Kaleshka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-02-25 00:00:00.000000000 Z
11
+ date: 2026-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -202,11 +202,13 @@ files:
202
202
  - lib/actual_db_schema/git.rb
203
203
  - lib/actual_db_schema/git_hooks.rb
204
204
  - lib/actual_db_schema/instrumentation.rb
205
+ - lib/actual_db_schema/middlewares/skip_pending_migration_check.rb
205
206
  - lib/actual_db_schema/migration.rb
206
207
  - lib/actual_db_schema/migration_context.rb
207
208
  - lib/actual_db_schema/migration_parser.rb
208
209
  - lib/actual_db_schema/multi_tenant.rb
209
210
  - lib/actual_db_schema/output_formatter.rb
211
+ - lib/actual_db_schema/patches/check_pending.rb
210
212
  - lib/actual_db_schema/patches/migration_context.rb
211
213
  - lib/actual_db_schema/patches/migration_proxy.rb
212
214
  - lib/actual_db_schema/patches/migrator.rb