switchman 3.0.13 → 3.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/switchman/active_record/database_configurations.rb +14 -0
- data/lib/switchman/version.rb +1 -1
- data/lib/tasks/switchman.rake +12 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 148d79c6d4c79ef51204c2d32718b30463814b56849effaaf9cacaf86789261d
|
4
|
+
data.tar.gz: 1db4039008bd8958e0dc918b0de81a85294f795f6aea23a1e68e592d6ddc691f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2ff7f714441d360a38125d7eea85ac3aba981d76fa8a8fceca527f499b7c1a90eb4dd2c91fcf6e292569089e35b077b7ad248cb069a3a9a0579071b93f54a0d
|
7
|
+
data.tar.gz: 7fc113c8b0a1ecdd6d5590401af399fc8f7dd220bc655c190e962870f5e64e2d1e922879e3515693713a9cc77b290913d38740102a29000c19071dab21c10844
|
@@ -3,6 +3,20 @@
|
|
3
3
|
module Switchman
|
4
4
|
module ActiveRecord
|
5
5
|
module DatabaseConfigurations
|
6
|
+
# key difference: For each env name, ensure only one writable config is returned
|
7
|
+
# since all should point to the same data, even if multiple are writable
|
8
|
+
# (Picks 'primary' since it is guaranteed to exist and switchman handles activating
|
9
|
+
# deploy through other means)
|
10
|
+
def configs_for(include_replicas: false, name: nil, **)
|
11
|
+
res = super
|
12
|
+
if name && !include_replicas
|
13
|
+
return nil unless name.end_with?('primary')
|
14
|
+
elsif !include_replicas
|
15
|
+
return res.select { |config| config.name.end_with?('primary') }
|
16
|
+
end
|
17
|
+
res
|
18
|
+
end
|
19
|
+
|
6
20
|
private
|
7
21
|
|
8
22
|
# key difference: assumes a hybrid two-tier structure; each third tier
|
data/lib/switchman/version.rb
CHANGED
data/lib/tasks/switchman.rake
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# In rails 7.0+ if you have only 1 db in the env it doesn't try to do explicit activation
|
4
|
+
# (and for rails purposes we only have one db per env because each database server is a separate env)
|
5
|
+
if Rails.version < '7.0'
|
6
|
+
task_prefix = ::Rake::Task.task_defined?('app:db:migrate') ? 'app:db' : 'db'
|
7
|
+
::Rake::Task["#{task_prefix}:migrate"].clear_actions.enhance do
|
8
|
+
::ActiveRecord::Tasks::DatabaseTasks.migrate
|
9
|
+
# Ensure this doesn't blow up when running inside the dummy app
|
10
|
+
Rake::Task["#{task_prefix}:_dump"].invoke
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
3
14
|
module Switchman
|
4
15
|
module Rake
|
5
16
|
def self.filter_database_servers(&block)
|
@@ -50,9 +61,7 @@ module Switchman
|
|
50
61
|
end
|
51
62
|
|
52
63
|
# classes - an array or proc, to activate as the current shard during the
|
53
|
-
# task.
|
54
|
-
# so that schema updates for non-default tables happen against all shards.
|
55
|
-
# this is handled automatically for the default migration tasks, below.
|
64
|
+
# task.
|
56
65
|
def self.shardify_task(task_name, classes: [::ActiveRecord::Base])
|
57
66
|
old_task = ::Rake::Task[task_name]
|
58
67
|
old_actions = old_task.actions.dup
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switchman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
8
8
|
- James Williams
|
9
9
|
- Jacob Fugal
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
date: 2022-03-23 00:00:00.000000000 Z
|
@@ -300,7 +300,7 @@ licenses:
|
|
300
300
|
- MIT
|
301
301
|
metadata:
|
302
302
|
rubygems_mfa_required: 'true'
|
303
|
-
post_install_message:
|
303
|
+
post_install_message:
|
304
304
|
rdoc_options: []
|
305
305
|
require_paths:
|
306
306
|
- lib
|
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
316
|
version: '0'
|
317
317
|
requirements: []
|
318
318
|
rubygems_version: 3.1.4
|
319
|
-
signing_key:
|
319
|
+
signing_key:
|
320
320
|
specification_version: 4
|
321
321
|
summary: Rails sharding magic
|
322
322
|
test_files: []
|