backfiller 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +5 -0
- data/README.md +4 -3
- data/backfiller.gemspec +1 -1
- data/lib/backfiller/configuration.rb +0 -2
- data/lib/backfiller/railtie.rb +0 -2
- data/lib/backfiller/runner.rb +5 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d546e155a0790fdb0190454b6f59ccfa7847000ea93e64c785b7af932446c2aa
|
4
|
+
data.tar.gz: f8fb83e301f507909783ac29eb405c80d7497c318915a6af2c3df803f2a85ce2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6741e63a19b01bbc57829817f558838ccbe31adc18ec53fcad2115b23cba122a396e4981d0b773ad46a3af3d531771efd29fbca5d20a700a9a849a31a196b2d4
|
7
|
+
data.tar.gz: 0bf707056834e42d4e94fcf50477d121eb4e2fb8b4b31a98e13eb5be926a7cb32d1260726fd10f14d43ed0c3631bafc5788257cc835dab551cba57d084250fc8
|
data/Changelog.md
ADDED
data/README.md
CHANGED
@@ -7,11 +7,11 @@ This gem maybe handly for `no-downtime` deployment especially when you need to f
|
|
7
7
|
|
8
8
|
## Typical no-downtime and non-locking cycle
|
9
9
|
|
10
|
-
* add
|
10
|
+
* add migration that adds new column (null: true)
|
11
11
|
* deploy and run migration task
|
12
12
|
* deploy code that starts filling new column in corresponding flows
|
13
13
|
* add backfill task
|
14
|
-
* deploy and run
|
14
|
+
* deploy and run backfill task
|
15
15
|
* [optional] add migration that invokes backfill task asn so keep all environments consistent (except production environment because we already backfilled data)
|
16
16
|
* add migration that disallow null values (null: false)
|
17
17
|
* deploy code that starts using new column
|
@@ -49,7 +49,7 @@ Or install it yourself as:
|
|
49
49
|
|
50
50
|
## Usage
|
51
51
|
|
52
|
-
Assume we
|
52
|
+
Assume we want to backfill `profiles.name` column from `users.first_name`, `users.last_name` columns.
|
53
53
|
|
54
54
|
Create backfill task into `db/backfill/profile_name.rb` and defined required methods:
|
55
55
|
|
@@ -148,6 +148,7 @@ class Backfill::ProfileName
|
|
148
148
|
#{connection.quote(row['profile_name'])},
|
149
149
|
)
|
150
150
|
SQL
|
151
|
+
end
|
151
152
|
connection.execute 'COMMIT'
|
152
153
|
end
|
153
154
|
|
data/backfiller.gemspec
CHANGED
data/lib/backfiller/railtie.rb
CHANGED
@@ -13,8 +13,6 @@ module Backfiller
|
|
13
13
|
|
14
14
|
config.batch_size = 1_000
|
15
15
|
|
16
|
-
config.connection_pool = defined?(ApplicationRecord) ? ApplicationRecord.connection_pool : ActiveRecord::Base.connection_pool
|
17
|
-
|
18
16
|
config.logger = defined?(ApplicationRecord) ? ApplicationRecord.logger : ActiveRecord::Base.logger
|
19
17
|
end
|
20
18
|
end
|
data/lib/backfiller/runner.rb
CHANGED
@@ -9,7 +9,7 @@ module Backfiller
|
|
9
9
|
|
10
10
|
def initialize(task_name)
|
11
11
|
@task = build_task(task_name)
|
12
|
-
@connection_pool = @task.respond_to?(:connection_pool) ? @task.connection_pool :
|
12
|
+
@connection_pool = @task.respond_to?(:connection_pool) ? @task.connection_pool : default_connection_pool
|
13
13
|
@batch_size = @task.respond_to?(:batch_size) ? @task.batch_size : Backfiller.batch_size
|
14
14
|
@process_method = @task.respond_to?(:process_row) ? @task.method(:process_row) : self.method(:process_row)
|
15
15
|
end
|
@@ -36,6 +36,10 @@ module Backfiller
|
|
36
36
|
|
37
37
|
###########################################################################
|
38
38
|
|
39
|
+
def default_connection_pool
|
40
|
+
defined?(ApplicationRecord) ? ApplicationRecord.connection_pool : ActiveRecord::Base.connection_pool
|
41
|
+
end
|
42
|
+
|
39
43
|
def acquire_connection
|
40
44
|
connection_pool.checkout
|
41
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backfiller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andriy Yanko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
77
|
- ".rspec"
|
78
|
+
- Changelog.md
|
78
79
|
- Gemfile
|
79
80
|
- README.md
|
80
81
|
- Rakefile
|