penthouse 0.5.0 → 0.6.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 +4 -4
- data/lib/penthouse/migrator.rb +22 -8
- data/lib/penthouse/version.rb +1 -1
- data/lib/tasks/penthouse.rake +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0632eea067e1cf85d45c912212bfa613d7c34566
|
4
|
+
data.tar.gz: 60a49d25ab6339cb567a4815b53df28fc6b30127
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e60e2fe6d903e61317ed5e4930d793dded2bbdb93c7762516a477ec18a9de783dfb1690cf22952ffab141acae16b54357a616a51754e79d117b36d75a268c80
|
7
|
+
data.tar.gz: 7d53645c0a228a3cd62c6854e7ede31d3a56b40e5d12f04d18758358c9e38fcec3a7716a2e6637f9ba6908c8f93220e02f4a2077a6f030e901d2ca98bec7abde
|
data/lib/penthouse/migrator.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# shamelessly copied & adjusted from Apartment
|
2
|
-
# @see https://github.com/influitive/apartment/blob/
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/penthouse/version.rb
CHANGED
data/lib/tasks/penthouse.rake
CHANGED
@@ -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
|