bleib 0.0.13 → 0.0.14

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: b8dd30747f77195d48b5d390b46264289b8e1c49fa20c59e3282ac6713a79494
4
+ data.tar.gz: bcbe6b32bd69c06463525f6c3b08567fdfc532e8763b4c715a9932e81ee1bad5
5
5
  SHA512:
6
- metadata.gz: 7c857068e4636b3aeefb506cc572828fc959f9ad4a3325e2dfa28de8fb8b3a1bc31f98f395e08c29c886a936be3ee3d42ec64b6979f6f225d2d424f8608008a2
7
- data.tar.gz: a96bc48b018df35c9caf618aaf1b9952f08b34872435277ccaf4bfbc0b56de2cb1ffb4b7b6822ba91480e55292cd765b9b5edb9c6bcf94b5b091815d5226a60e
6
+ metadata.gz: add4d3ffa793ad2f0799fd54858fc282c59534ebb4d91ea0206053e1bbc939b84422ebb6c1eba12ccaa68d5f6b5ddf8123791e98b07d375a62c56e5430cd7af8
7
+ data.tar.gz: e78186dc2516bd072864ada0ce45d5c545882aaa34050a5cf15c0f610dfa712d590e1ddcf1c096123790b95123a669619e990859aabc8e1413a450fe54e0265f
@@ -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,30 @@ 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!
58
+ check_wagon_migrations! if wagons_gem?
53
59
  ActiveRecord::Migration.check_pending!
54
60
  end
55
61
 
56
- def in_all_tenant_contexts
62
+ def check_wagon_migrations!
63
+ paths = Wagons.all.flat_map(&:migrations_paths)
64
+ context = ActiveRecord::MigrationContext.new(paths, ActiveRecord::SchemaMigration)
65
+
66
+ # we do not need the correct output, just the right exception
67
+ # in this case, the output only considers the main-app migration, not the ones in wagons
68
+ raise ActiveRecord::PendingMigrationError if context.needs_migration?
69
+ end
70
+
71
+ def in_all_tenant_contexts(&block)
57
72
  tenants = [ENV.fetch('BLEIB_DEFAULT_TENANT', 'public')] +
58
73
  Apartment.tenant_names
59
74
 
60
75
  tenants.uniq.each do |tenant|
61
- Apartment::Tenant.switch(tenant) do
62
- yield
63
- end
76
+ Apartment::Tenant.switch(tenant, &block)
64
77
  end
65
78
  end
66
79
 
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.14'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.14
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
11
+ date: 2024-09-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Intended for use in containerized setups where another component takes
14
14
  care of migrating the database.
@@ -24,28 +24,27 @@ files:
24
24
  - lib/bleib/railtie.rb
25
25
  - lib/bleib/version.rb
26
26
  - lib/tasks/bleib.rake
27
- homepage: https://rubygems.org/gems/bleib
27
+ homepage: https://github.com/puzzle/bleib
28
28
  licenses:
29
29
  - MIT
30
30
  metadata:
31
31
  source_code_uri: https://github.com/puzzle/bleib
32
- documentation_uri: https://github.com/puzzle/bleib
33
32
  post_install_message:
34
33
  rdoc_options: []
35
34
  require_paths:
36
35
  - lib
37
36
  required_ruby_version: !ruby/object:Gem::Requirement
38
37
  requirements:
39
- - - ">="
38
+ - - ">"
40
39
  - !ruby/object:Gem::Version
41
- version: '0'
40
+ version: '3.0'
42
41
  required_rubygems_version: !ruby/object:Gem::Requirement
43
42
  requirements:
44
43
  - - ">="
45
44
  - !ruby/object:Gem::Version
46
45
  version: '0'
47
46
  requirements: []
48
- rubygems_version: 3.3.26
47
+ rubygems_version: 3.5.10
49
48
  signing_key:
50
49
  specification_version: 4
51
50
  summary: Use a rake task to wait on database and migrations.