bleib 0.0.13 → 0.0.15

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: ea9b6fd929ee2479f6a1cc9e756da6d1ad93b42b2aa18c0a81d514b0986e6f2b
4
- data.tar.gz: 158a3043d275f29cd92157fbbfd97f9a9a3ffcc9567b55fab8c1728691d00540
3
+ metadata.gz: 3e1f9c38f0f6a8e80404b67b52fc01cc7d43c6d57d5baf6c383b0320e0c4c3d3
4
+ data.tar.gz: 3eafe905d3cd65ba687e45e6bdaa2b342be55941a398cdcedd9654ba2fcc38a2
5
5
  SHA512:
6
- metadata.gz: 7c857068e4636b3aeefb506cc572828fc959f9ad4a3325e2dfa28de8fb8b3a1bc31f98f395e08c29c886a936be3ee3d42ec64b6979f6f225d2d424f8608008a2
7
- data.tar.gz: a96bc48b018df35c9caf618aaf1b9952f08b34872435277ccaf4bfbc0b56de2cb1ffb4b7b6822ba91480e55292cd765b9b5edb9c6bcf94b5b091815d5226a60e
6
+ metadata.gz: 2ff7f0d01d721a956b04872eeaabd2194f816ac8e97617388212818357b6398d1f727321b4c47b79ea0e1f7fe5f5f5c81752a3197264158b9dfd462be52788bf
7
+ data.tar.gz: 3e40efa8504edc316b56a99d9cacdeb629d0a5e4c42fbd0d08ae656452072bf079791d1c3eb7faae228ba532115990e3d2052fbc50e50cdc6778e8a9253b9836
@@ -2,15 +2,16 @@ module Bleib
2
2
  # Finds out if all migrations are up.
3
3
  #
4
4
  # Knows how to handle multitenancy with Apartment, if used.
5
+ # Checks also migrations with Wagons, if used.
5
6
  class Migrations
6
7
  def initialize(configuration)
7
8
  @configuration = configuration
8
9
  end
9
10
 
10
11
  def wait_until_done
11
- logger.info('Waiting for migrations' \
12
- ' (Also checking apartment tenants:' \
13
- " #{apartment_gem? ? 'yes' : 'no'})")
12
+ logger.info('Waiting for migrations')
13
+ logger.info('Also checking apartment tenants:' + " #{apartment_gem? ? 'yes' : 'no'}")
14
+ logger.info('Also checking wagon migrations:' + " #{wagons_gem? ? 'yes' : 'no'}")
14
15
 
15
16
  wait while pending_migrations?
16
17
 
@@ -49,18 +50,36 @@ module Bleib
49
50
  defined?(Apartment::Tenant)
50
51
  end
51
52
 
53
+ def wagons_gem?
54
+ defined?(Wagons)
55
+ end
56
+
52
57
  def check_migrations!
53
- ActiveRecord::Migration.check_pending!
58
+ check_wagon_migrations! if wagons_gem?
59
+
60
+ # https://apidock.com/rails/v7.1.3.4/ActiveRecord/Migration/check_pending
61
+ if Rails::VERSION::MAJOR < 7 || (Rails::VERSION::MAJOR == 7 && Rails::VERSION::MINOR.zero?)
62
+ ActiveRecord::Migration.check_pending!
63
+ else
64
+ ActiveRecord::Migration.check_all_pending!
65
+ end
66
+ end
67
+
68
+ def check_wagon_migrations!
69
+ paths = Wagons.all.flat_map(&:migrations_paths)
70
+ context = ActiveRecord::MigrationContext.new(paths, ActiveRecord::SchemaMigration)
71
+
72
+ # we do not need the correct output, just the right exception
73
+ # in this case, the output only considers the main-app migration, not the ones in wagons
74
+ raise ActiveRecord::PendingMigrationError if context.needs_migration?
54
75
  end
55
76
 
56
- def in_all_tenant_contexts
77
+ def in_all_tenant_contexts(&block)
57
78
  tenants = [ENV.fetch('BLEIB_DEFAULT_TENANT', 'public')] +
58
79
  Apartment.tenant_names
59
80
 
60
81
  tenants.uniq.each do |tenant|
61
- Apartment::Tenant.switch(tenant) do
62
- yield
63
- end
82
+ Apartment::Tenant.switch(tenant, &block)
64
83
  end
65
84
  end
66
85
 
data/lib/bleib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bleib
4
- VERSION = '0.0.13'
4
+ VERSION = '0.0.15'
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bleib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puzzle ITC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-04 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-12-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Intended for use in containerized setups where another component takes
14
28
  care of migrating the database.
15
29
  email: viehweger@puzzle.ch
@@ -24,28 +38,27 @@ files:
24
38
  - lib/bleib/railtie.rb
25
39
  - lib/bleib/version.rb
26
40
  - lib/tasks/bleib.rake
27
- homepage: https://rubygems.org/gems/bleib
41
+ homepage: https://github.com/puzzle/bleib
28
42
  licenses:
29
43
  - MIT
30
44
  metadata:
31
45
  source_code_uri: https://github.com/puzzle/bleib
32
- documentation_uri: https://github.com/puzzle/bleib
33
46
  post_install_message:
34
47
  rdoc_options: []
35
48
  require_paths:
36
49
  - lib
37
50
  required_ruby_version: !ruby/object:Gem::Requirement
38
51
  requirements:
39
- - - ">="
52
+ - - ">"
40
53
  - !ruby/object:Gem::Version
41
- version: '0'
54
+ version: '3.0'
42
55
  required_rubygems_version: !ruby/object:Gem::Requirement
43
56
  requirements:
44
57
  - - ">="
45
58
  - !ruby/object:Gem::Version
46
59
  version: '0'
47
60
  requirements: []
48
- rubygems_version: 3.3.26
61
+ rubygems_version: 3.5.22
49
62
  signing_key:
50
63
  specification_version: 4
51
64
  summary: Use a rake task to wait on database and migrations.