nandi 0.10.0 → 0.12.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
  SHA256:
3
- metadata.gz: ff51dca733bf2e4a5bff9ff71ac930c6d849fa734106a31b1244777fb25db9c0
4
- data.tar.gz: ceeaebbaee681e1a4e6e857ec32289d59d821b9c627f899b371b607c214b077a
3
+ metadata.gz: 1da0a62d10387d4dc47b1b00045d351559d8c3a6a08b9f3de2ad029b7948e0da
4
+ data.tar.gz: f56710ba940ee97e004113b9d96aa6a5e4cc34b963f9c2d5dcbd8d3ae6c4b893
5
5
  SHA512:
6
- metadata.gz: aa53ecf85370d256a09197547d0d99ceb4a3f731620f25341ea05b44364749ba452a3f375554f180879426b1b757f0b551cca1e86ede08f755070adcb62a879f
7
- data.tar.gz: 80f8945b42a0931dced7e02e83ff0c43e4173009d9d5e6f74c876f18f5fe037280488cd524fce8683301001a86eacdcc9df6674ea649ef1ae71f2b9a1fa6c2f5
6
+ metadata.gz: 5f9a1879fa3f414c020703cf521200a1d436f2af0da8b7051beadd91bbadf9556f3e811eef17d842e54b8c962b4051529f347b8900dda3ffe5c887bc4565928f
7
+ data.tar.gz: fcbbc52d37437d8052016e3ff1182f3b603994ab002827ef7e6fbb182ee2a816ff383abde467f0c12f99da54141cbe8ffccb99748950143d047f04233e220733
data/README.md CHANGED
@@ -4,7 +4,7 @@ Friendly Postgres migrations for people who don't want to take down their databa
4
4
 
5
5
  ## Supported
6
6
 
7
- - Ruby 2.4 or above
7
+ - Ruby 2.5 or above
8
8
  - Rails 5.2 or above
9
9
  - Postgres 11 or above
10
10
 
data/exe/nandi-enforce CHANGED
@@ -31,6 +31,6 @@ OptionParser.new do |o|
31
31
  end
32
32
  end.parse!
33
33
 
34
- enforcer = Nandi::SafeMigrationEnforcer.new(opts)
34
+ enforcer = Nandi::SafeMigrationEnforcer.new(**opts)
35
35
 
36
36
  enforcer.run
@@ -37,7 +37,7 @@ module Nandi
37
37
  end
38
38
 
39
39
  def ignored_filenames
40
- ignored_files.map(&File.method(:basename))
40
+ ignored_files.map { |file| File.basename(file) }
41
41
  end
42
42
 
43
43
  def match_timestamp
@@ -8,7 +8,12 @@ module Nandi
8
8
  def initialize(table:, name:, **extra_args)
9
9
  @table = table
10
10
  @name = name
11
- @extra_args = extra_args if extra_args.any?
11
+ @extra_args =
12
+ if extra_args.any?
13
+ extra_args
14
+ else
15
+ {}
16
+ end
12
17
  end
13
18
 
14
19
  def procedure
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/core_ext/hash/indifferent_access"
4
+ require "digest"
4
5
 
5
6
  module Nandi
6
7
  class Lockfile
@@ -42,7 +43,26 @@ module Nandi
42
43
  end
43
44
 
44
45
  def persist!
45
- File.write(path, lockfile.to_h.deep_stringify_keys.to_yaml)
46
+ # This is a somewhat ridiculous trick to avoid merge conflicts in git.
47
+ #
48
+ # Normally, new migrations are added to the bottom of the Nandi lockfile.
49
+ # This is relatively unfriendly to git's merge algorithm, and means that
50
+ # if someone merges a pull request with a completely unrelated migration,
51
+ # you'll have to rebase to get yours merged as the last line of the file
52
+ # will be seen as a conflict (both branches added content there).
53
+ #
54
+ # This is in contrast to something like Gemfile.lock, where changes tend
55
+ # to be distributed throughout the file. The idea behind sorting by
56
+ # SHA-256 hash is to distribute new Nandi lockfile entries evenly, but
57
+ # also stably through the file. It needs to be stable or we'd have even
58
+ # worse merge conflict problems (e.g. if we randomised the order on
59
+ # writing the file, the whole thing would conflict pretty much every time
60
+ # it was regenerated).
61
+ content = lockfile.to_h.deep_stringify_keys.sort_by do |k, _|
62
+ Digest::SHA256.hexdigest(k)
63
+ end.to_h.to_yaml
64
+
65
+ File.write(path, content)
46
66
  end
47
67
 
48
68
  def path
@@ -357,9 +357,9 @@ module Nandi
357
357
  end.uniq
358
358
  end
359
359
 
360
- def method_missing(name, *args, &block)
360
+ def method_missing(name, *args, **kwargs, &block)
361
361
  if Nandi.config.custom_methods.key?(name)
362
- invoke_custom_method(name, *args, &block)
362
+ invoke_custom_method(name, *args, **kwargs, &block)
363
363
  else
364
364
  super
365
365
  end
@@ -381,9 +381,9 @@ module Nandi
381
381
  Nandi.config.access_exclusive_lock_timeout
382
382
  end
383
383
 
384
- def invoke_custom_method(name, *args, &block)
384
+ def invoke_custom_method(name, *args, **kwargs, &block)
385
385
  klass = Nandi.config.custom_methods[name]
386
- current_instructions << klass.new(*args, &block)
386
+ current_instructions << klass.new(*args, **kwargs, &block)
387
387
  end
388
388
  end
389
389
  end
@@ -30,7 +30,7 @@ module Nandi
30
30
 
31
31
  def should_disable_ddl_transaction?
32
32
  [*up_instructions, *down_instructions].
33
- select { |i| i.procedure =~ /index/ }.any?
33
+ select { |i| i.procedure.to_s.include?("index") }.any?
34
34
  end
35
35
 
36
36
  def activerecord_version
@@ -24,7 +24,9 @@ module Nandi
24
24
  private
25
25
 
26
26
  def timeout_policies
27
- instructions.map(&Nandi::TimeoutPolicies.method(:policy_for)).uniq
27
+ instructions.map do |instruction|
28
+ Nandi::TimeoutPolicies.policy_for(instruction)
29
+ end.uniq
28
30
  end
29
31
 
30
32
  def instructions
data/lib/nandi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nandi
4
- VERSION = "0.10.0"
4
+ VERSION = "0.12.0"
5
5
  end
@@ -2,5 +2,5 @@ add_column(
2
2
  <%= table %>,
3
3
  <%= name %>,
4
4
  <%= type %>,
5
- <%= extra_args %>
5
+ **<%= extra_args || {} %>
6
6
  )
@@ -1,5 +1,5 @@
1
1
  add_foreign_key(
2
2
  <%= table %>,
3
3
  <%= target %>,
4
- <%= extra_args %>
4
+ **<%= extra_args || {} %>
5
5
  )
@@ -1,5 +1,5 @@
1
1
  add_index(
2
2
  <%= table %>,
3
3
  <%= fields %>,
4
- <%= extra_args %>
4
+ **<%= extra_args || {} %>
5
5
  )
@@ -1,5 +1,5 @@
1
1
  add_reference(
2
2
  <%= table %>,
3
3
  <%= ref_name %>,
4
- <%= extra_args %>
4
+ **<%= extra_args || {} %>
5
5
  )
@@ -1,5 +1,5 @@
1
1
  remove_column(
2
2
  <%= table %>,
3
3
  <%= name %>,
4
- <%= extra_args %>
4
+ **<%= extra_args || {} %>
5
5
  )
@@ -1,4 +1,4 @@
1
1
  remove_index(
2
2
  <%= table %>,
3
- <%= extra_args %>
3
+ **<%= extra_args || {} %>
4
4
  )
@@ -1,5 +1,5 @@
1
1
  remove_reference(
2
2
  <%= table %>,
3
3
  <%= ref_name %>,
4
- <%= extra_args %>
4
+ **<%= extra_args || {} %>
5
5
  )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nandi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless Engineering
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-16 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 2.15.0
103
+ version: 2.25.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 2.15.0
110
+ version: 2.25.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: pry-byebug
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -212,7 +212,7 @@ dependencies:
212
212
  - - "~>"
213
213
  - !ruby/object:Gem::Version
214
214
  version: '0.9'
215
- description:
215
+ description:
216
216
  email:
217
217
  - engineering@gocardless.com
218
218
  executables:
@@ -303,7 +303,7 @@ homepage: https://github.com/gocardless/nandi
303
303
  licenses:
304
304
  - MIT
305
305
  metadata: {}
306
- post_install_message:
306
+ post_install_message:
307
307
  rdoc_options: []
308
308
  require_paths:
309
309
  - lib
@@ -318,8 +318,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
318
318
  - !ruby/object:Gem::Version
319
319
  version: '0'
320
320
  requirements: []
321
- rubygems_version: 3.1.2
322
- signing_key:
321
+ rubygems_version: 3.3.3
322
+ signing_key:
323
323
  specification_version: 4
324
324
  summary: Fear-free migrations for PostgreSQL
325
325
  test_files: []