safe-pg-migrations 1.2.0 → 1.2.1

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: e6c0ad1795c94252929d907f94e3cf65617ca9a353414d031fb74a852ee294ea
4
- data.tar.gz: f2d1045f55ff1896ef045edb4fe2868b7f26bc4e1b7cc542907eaab08da91075
3
+ metadata.gz: fbda5becc48b8f9c7e0f45820f5f9ef908ba1f1fe56c306f03d3f76fb0197741
4
+ data.tar.gz: 4e88da86831d71cb440e1409ad52f3591aabcbd26de248507daffbec0e17698d
5
5
  SHA512:
6
- metadata.gz: 3b32973e6920a5db9d7d48440cc5ac09fbdd511539dcf3ec436584584d6a9b501a1027a212d991a27e47ae9a20e471cabc6d705e42f6324eb79eb1b529186f1f
7
- data.tar.gz: 0c006975e25f1c318caa3375a05c1aa43a45c50813ef6b03a4d4d7d842b5c5a2188243744a8f4e769196c39ef6ca162c693a22b48dec1c38f13aa4b1d61bfc80
6
+ metadata.gz: e7dfbc18db1959f66a104e37d1f880934b369338b96435efc2db851fe80c092e9cf1e19a092274726dcb35da2fb05035d71a63e404dc89366de6c3483ce2131f
7
+ data.tar.gz: a176ae5e044b31ef271359aa9342698e1744e00c3fe99eb8f10c65fa77127671bf5265f4a4e65117df2f22bbc01bbc201ea22ecd2e0faca36e0822cc2f85e2b9
@@ -4,7 +4,7 @@ module SafePgMigrations
4
4
  module StatementInsurer
5
5
  PG_11_VERSION_NUM = 110_000
6
6
 
7
- %i[change_column_null change_column create_table].each do |method|
7
+ %i[change_column_null change_column].each do |method|
8
8
  define_method method do |*args, &block|
9
9
  with_setting(:statement_timeout, SafePgMigrations.config.pg_safe_timeout) { super(*args, &block) }
10
10
  end
@@ -46,8 +46,25 @@ module SafePgMigrations
46
46
  without_statement_timeout { validate_foreign_key from_table, options_or_to_table } unless validate_present
47
47
  end
48
48
 
49
+ def create_table(*)
50
+ with_setting(:statement_timeout, SafePgMigrations.config.pg_safe_timeout) do
51
+ super do |td|
52
+ yield td if block_given?
53
+ td.indexes.map! do |key, index_options|
54
+ index_options[:algorithm] ||= :default
55
+ [key, index_options]
56
+ end
57
+ end
58
+ end
59
+ end
60
+
49
61
  def add_index(table_name, column_name, **options)
50
- options[:algorithm] = :concurrently
62
+ if options[:algorithm] == :default
63
+ options.delete :algorithm
64
+ else
65
+ options[:algorithm] = :concurrently
66
+ end
67
+
51
68
  SafePgMigrations.say_method_call(:add_index, table_name, column_name, options)
52
69
 
53
70
  without_timeout { super }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SafePgMigrations
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.1'
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safe-pg-migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu Prat
8
8
  - Romain Choquet
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-11-30 00:00:00.000000000 Z
12
+ date: 2021-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -174,7 +174,7 @@ homepage: https://github.com/doctolib/safe-pg-migrations
174
174
  licenses:
175
175
  - MIT
176
176
  metadata: {}
177
- post_install_message:
177
+ post_install_message:
178
178
  rdoc_options: []
179
179
  require_paths:
180
180
  - lib
@@ -189,9 +189,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
- rubyforge_project:
192
+ rubyforge_project:
193
193
  rubygems_version: 2.7.3
194
- signing_key:
194
+ signing_key:
195
195
  specification_version: 4
196
196
  summary: Make your PG migrations safe.
197
197
  test_files: []