penthouse 0.5.0 → 0.6.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
  SHA1:
3
- metadata.gz: 793411262ca8ce30ae1f03de55a78f76d4f4d9a2
4
- data.tar.gz: 28306b0b4536d295809080968dfd0a2fd7621318
3
+ metadata.gz: 0632eea067e1cf85d45c912212bfa613d7c34566
4
+ data.tar.gz: 60a49d25ab6339cb567a4815b53df28fc6b30127
5
5
  SHA512:
6
- metadata.gz: 16ce8d5d39cdc76572d89a91ea895986fbd90d9fb59021f6f5a9fd65a7dc76f49121752c69a49d63fceaa48f0da2132547573c8b3df0f472668adc7e0b7140ee
7
- data.tar.gz: 5948007a8f5c28089a94e3f48d60f55110b5f67c4b2cc9bf2fb7b7372f5047930253610d0b1d3ec66e5594a2470ebaea70b3df375a273257a0237e27d6832513
6
+ metadata.gz: 6e60e2fe6d903e61317ed5e4930d793dded2bbdb93c7762516a477ec18a9de783dfb1690cf22952ffab141acae16b54357a616a51754e79d117b36d75a268c80
7
+ data.tar.gz: 7d53645c0a228a3cd62c6854e7ede31d3a56b40e5d12f04d18758358c9e38fcec3a7716a2e6637f9ba6908c8f93220e02f4a2077a6f030e901d2ca98bec7abde
@@ -1,5 +1,7 @@
1
1
  # shamelessly copied & adjusted from Apartment
2
- # @see https://github.com/influitive/apartment/blob/development/lib/apartment/migrator.rb
2
+ # @see https://github.com/influitive/apartment/blob/master/lib/apartment/migrator.rb
3
+ # overrides Octopus's auto-switching to shards
4
+ # @see https://github.com/thiagopradi/octopus/blob/master/lib/octopus/migration.rb
3
5
 
4
6
  module Penthouse
5
7
  module Migrator
@@ -9,12 +11,12 @@ module Penthouse
9
11
  # Migrate to latest version
10
12
  # @param tenant_identifier [String, Symbol] the identifier for the tenant to switch to
11
13
  # @return [void]
12
- def migrate(tenant_identifier)
14
+ def migrate(tenant_identifier, version)
13
15
  Penthouse.switch(tenant_identifier) do
14
- version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
15
-
16
- ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, version) do |migration|
17
- ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope)
16
+ if migrator.respond_to?(:migrate_without_octopus)
17
+ migrator.migrate_without_octopus(migrator.migrations_paths, version)
18
+ else
19
+ migrator.migrate(migrator.migrations_paths, version)
18
20
  end
19
21
  end
20
22
  end
@@ -25,7 +27,11 @@ module Penthouse
25
27
  # @return [void]
26
28
  def run(direction, tenant_identifier, version)
27
29
  Penthouse.switch(tenant_identifier) do
28
- ActiveRecord::Migrator.run(direction, ActiveRecord::Migrator.migrations_paths, version)
30
+ if migrator.respond_to?(:run_without_octopus)
31
+ migrator.run_without_octopus(direction, migrator.migrations_paths, version)
32
+ else
33
+ migrator.run(direction, migrator.migrations_paths, version)
34
+ end
29
35
  end
30
36
  end
31
37
 
@@ -35,8 +41,16 @@ module Penthouse
35
41
  # @return [void]
36
42
  def rollback(tenant_identifier, step = 1)
37
43
  Penthouse.switch(tenant_identifier) do
38
- ActiveRecord::Migrator.rollback(ActiveRecord::Migrator.migrations_paths, step)
44
+ if migrator.respond_to?(:rollback_without_octopus)
45
+ migrator.rollback_without_octopus(migrator.migrations_paths, step)
46
+ else
47
+ migrator.rollback(migrator.migrations_paths, step)
48
+ end
39
49
  end
40
50
  end
51
+
52
+ def migrator
53
+ ActiveRecord::Migrator
54
+ end
41
55
  end
42
56
  end
@@ -1,3 +1,3 @@
1
1
  module Penthouse
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -6,10 +6,12 @@ penthouse_namespace = namespace :penthouse do
6
6
  task :migrate do
7
7
  warn_if_tenants_empty
8
8
 
9
+ version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
10
+
9
11
  tenant_identifiers.each do |tenant_identifier|
10
12
  begin
11
13
  puts("Migrating #{tenant_identifier || '***global***'} tenant")
12
- Penthouse::Migrator.migrate(tenant_identifier)
14
+ Penthouse::Migrator.migrate(tenant_identifier, version)
13
15
  rescue Penthouse::TenantNotFound => e
14
16
  puts e.message
15
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: penthouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Townsend