activerecord-safer_migrations 2.0.0 → 3.0.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
- SHA1:
3
- metadata.gz: 22edc1b74891b126918870a164f1213a79e92627
4
- data.tar.gz: 153a817bf13c44c28a22ba7048756e4d61dcaf43
2
+ SHA256:
3
+ metadata.gz: d13f83c80f1349c377b473f62e9bd4c3be66b3951d5aa21cf9deb02a455338b3
4
+ data.tar.gz: ecae2f7ef31aeb43a8631dcc8aeab9387bb05a9117067af022e3f65f146b221b
5
5
  SHA512:
6
- metadata.gz: 5cd1cfa6177e67981bf0060740d899504ab15945f59e48627b7053450483fd50bd7bbeaac137ef1410ac30b5c35a07b6d86935114b469d7902519875711c9e78
7
- data.tar.gz: 75866edc3cfb0eac725953860a47f80f72212803b5f40f49cd62cc474720da6b13e83b882dfccc78f5b6b3e88369126a36a460ea45b080bb65a1b95cca4b9157
6
+ metadata.gz: 1e8c83b7626aea99e64e2b496cb57a5af1979f8697a7b760bed228e07a9837356b3a30671d9c66094fd858086bfe2ca773142b24a33f6ae4c15b65ebccfd0fd0
7
+ data.tar.gz: a62709f4e0e134b3d38550cdb5b0d4b6b752a7c2e669f89b1ad550c2b1b267bff1e2335b50b6ccbc1678ae8c9b960c18c05ae988434a5b1be1724e309cbf7ba9
@@ -0,0 +1,55 @@
1
+ version: 2.1
2
+
3
+ jobs:
4
+ test:
5
+ docker:
6
+ - image: circleci/ruby:<< parameters.ruby-version >>
7
+ - image: postgres:11.3
8
+ environment:
9
+ POSTGRES_USER: postgres
10
+ POSTGRES_DB: safer_migrations_test
11
+ POSTGRES_PASSWORD: ""
12
+ POSTGRES_HOST_AUTH_METHOD: trust
13
+ environment:
14
+ DATABASE_URL: postgres://postgres@localhost/safer_migrations_test
15
+ ACTIVERECORD_VERSION: << parameters.activerecord-version >>
16
+ parameters:
17
+ ruby-version:
18
+ type: string
19
+ activerecord-version:
20
+ type: string
21
+ steps:
22
+ - checkout
23
+ - restore_cache:
24
+ keys:
25
+ - bundle-v1-<< parameters.ruby-version >>-{{ checksum "activerecord-safer_migrations.gemspec" }}
26
+ - bundle-v1-<< parameters.ruby-version >>-
27
+ - run:
28
+ name: Install dependencies
29
+ command: bundle install --clean --no-cache --path vendor/bundle --jobs=4 --retry=3
30
+ - save_cache:
31
+ key: bundle-v1-<< parameters.ruby-version >>-{{ checksum "activerecord-safer_migrations.gemspec" }}
32
+ paths:
33
+ - vendor/bundle
34
+ - run:
35
+ name: Run tests
36
+ command: bundle exec rspec
37
+ - run:
38
+ name: Run rubocop
39
+ command: bundle exec rubocop --parallel --extra-details --display-style-guide
40
+
41
+ workflows:
42
+ default:
43
+ jobs:
44
+ - test:
45
+ name: "Ruby << matrix.ruby-version >> : ActiveRecord << matrix.activerecord-version >>"
46
+ matrix:
47
+ parameters:
48
+ activerecord-version:
49
+ - 5.2.4.4
50
+ - 6.0.3.3
51
+ ruby-version:
52
+ - 2.5.8
53
+ - 2.6.6
54
+ - 2.7.1
55
+ # - 3.0.0-preview1
@@ -1,30 +1,10 @@
1
- AllCops:
2
- DisplayCopNames: true
3
-
4
- # Use trailing rather than leading dots on multi-line call chains
5
- Style/DotPosition:
6
- EnforcedStyle: trailing
7
-
8
- Style/Documentation:
9
- Enabled: false
10
-
11
- Style/StringLiterals:
12
- EnforcedStyle: double_quotes
1
+ inherit_from: .rubocop_todo.yml
13
2
 
14
- Style/TrailingComma:
15
- EnforcedStyleForMultiline: comma
3
+ inherit_gem:
4
+ gc_ruboconfig: rubocop.yml
16
5
 
17
- Style/AccessorMethodName:
18
- Enabled: false
19
-
20
- Style/SignalException:
21
- EnforcedStyle: only_raise
22
-
23
- Style/GlobalVars:
24
- Enabled: false
6
+ AllCops:
7
+ TargetRubyVersion: 2.7
25
8
 
26
- Style/FileName:
9
+ Gemspec/RequiredRubyVersion:
27
10
  Enabled: false
28
-
29
- Metrics/LineLength:
30
- Max: 100
@@ -0,0 +1,20 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-03-27 12:04:06 +0100 using RuboCop version 0.54.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
11
+ # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
12
+ Naming/FileName:
13
+ Exclude:
14
+ - 'lib/activerecord-safer_migrations.rb'
15
+
16
+ # Offense count: 20
17
+ # Configuration parameters: AllowedVariables.
18
+ Style/GlobalVars:
19
+ Exclude:
20
+ - 'spec/active_record/safer_migrations/migration_spec.rb'
@@ -1 +1 @@
1
- 2.4.1
1
+ 2.7.1
@@ -1,3 +1,7 @@
1
+ # 3.0.0 / 2020-09-28
2
+
3
+ - [#55](https://github.com/gocardless/activerecord-safer_migrations/pull/55) Drop support for Ruby =< 2.4 and Rails =< 5.1
4
+
1
5
  # 2.0.0 / 2017-08-23
2
6
 
3
7
  - [#23](https://github.com/gocardless/activerecord-safer_migrations/pull/23) Drop support for Rails 4.0 and 4.1
data/Gemfile CHANGED
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  gemspec
4
6
 
5
7
  gem "activerecord", "~> #{ENV['ACTIVERECORD_VERSION']}" if ENV["ACTIVERECORD_VERSION"]
8
+ gem "gc_ruboconfig", "~> 2.19.0"
@@ -1,4 +1,6 @@
1
- require File.expand_path("../lib/active_record/safer_migrations/version", __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("lib/active_record/safer_migrations/version", __dir__)
2
4
 
3
5
  Gem::Specification.new do |gem|
4
6
  gem.name = "activerecord-safer_migrations"
@@ -12,11 +14,11 @@ Gem::Specification.new do |gem|
12
14
  gem.homepage = "https://github.com/gocardless/activerecord-safer_migrations"
13
15
  gem.license = "MIT"
14
16
 
15
- gem.required_ruby_version = "~> 2.2"
17
+ gem.required_ruby_version = ">= 2.5"
16
18
 
17
- gem.add_runtime_dependency "activerecord", ">= 4.0"
19
+ gem.add_runtime_dependency "activerecord", ">= 5.2"
18
20
 
19
- gem.add_development_dependency "pg", "~> 0.21.0"
20
- gem.add_development_dependency "rspec", "~> 3.3.0"
21
- gem.add_development_dependency "rubocop", "~> 0.35.1"
21
+ gem.add_development_dependency "pg", "~> 1.2.3"
22
+ gem.add_development_dependency "rspec", "~> 3.9.0"
23
+ gem.add_development_dependency "rubocop", "~> 0.92.0"
22
24
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_record/safer_migrations/setting_helper"
2
4
 
3
5
  module ActiveRecord
@@ -19,9 +21,12 @@ module ActiveRecord
19
21
  def exec_migration(conn, direction)
20
22
  # lock_timeout is an instance accessor created by class_attribute
21
23
  lock_timeout_ms = lock_timeout || SaferMigrations.default_lock_timeout
22
- statement_timeout_ms = statement_timeout || SaferMigrations.default_statement_timeout
24
+ statement_timeout_ms = statement_timeout || SaferMigrations.
25
+ default_statement_timeout
23
26
  SettingHelper.new(conn, :lock_timeout, lock_timeout_ms).with_setting do
24
- SettingHelper.new(conn, :statement_timeout, statement_timeout_ms).with_setting do
27
+ SettingHelper.new(conn,
28
+ :statement_timeout,
29
+ statement_timeout_ms).with_setting do
25
30
  super(conn, direction)
26
31
  end
27
32
  end
@@ -29,8 +34,10 @@ module ActiveRecord
29
34
  end
30
35
 
31
36
  module ClassMethods
37
+ # rubocop:disable Naming/AccessorMethodName
32
38
  def set_lock_timeout(timeout)
33
- if timeout == 0
39
+ # rubocop:enable Naming/AccessorMethodName
40
+ if timeout.zero?
34
41
  raise "Setting lock_timeout to 0 is dangerous - it disables the lock " \
35
42
  "timeout rather than instantly timing out. If you *actually* " \
36
43
  "want to disable the lock timeout (not recommended!), use the " \
@@ -44,12 +51,14 @@ module ActiveRecord
44
51
  self.lock_timeout = 0
45
52
  end
46
53
 
54
+ # rubocop:disable Naming/AccessorMethodName
47
55
  def set_statement_timeout(timeout)
48
- if timeout == 0
49
- raise "Setting statement_timeout to 0 is dangerous - it disables the statement " \
50
- "timeout rather than instantly timing out. If you *actually* " \
51
- "want to disable the statement timeout (not recommended!), use the " \
52
- "`disable_statement_timeout!` method."
56
+ # rubocop:enable Naming/AccessorMethodName
57
+ if timeout.zero?
58
+ raise "Setting statement_timeout to 0 is dangerous - it disables the " \
59
+ "statement timeout rather than instantly timing out. If you " \
60
+ "*actually* want to disable the statement timeout (not recommended!)" \
61
+ ", use the `disable_statement_timeout!` method."
53
62
  end
54
63
  self.statement_timeout = timeout
55
64
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  module SaferMigrations
3
5
  module PostgreSQLAdapter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  module SaferMigrations
3
5
  class Railtie < Rails::Railtie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  module SaferMigrations
3
5
  class SettingHelper
@@ -20,7 +22,7 @@ module ActiveRecord
20
22
  set_new_setting
21
23
  yield
22
24
  reset_setting
23
- rescue
25
+ rescue StandardError
24
26
  reset_setting unless in_transaction?
25
27
  raise
26
28
  end
@@ -42,7 +44,7 @@ module ActiveRecord
42
44
  end
43
45
 
44
46
  def in_transaction?
45
- ActiveRecord::Base.connection.open_transactions > 0
47
+ ActiveRecord::Base.connection.open_transactions.positive?
46
48
  end
47
49
  end
48
50
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  module SaferMigrations
3
- VERSION = "2.0.0".freeze
5
+ VERSION = "3.0.0"
4
6
  end
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_record/connection_adapters/postgresql_adapter"
2
4
  require "active_record/safer_migrations/postgresql_adapter"
3
5
  require "active_record/safer_migrations/migration"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  RSpec.describe ActiveRecord::SaferMigrations::Migration do
@@ -9,13 +11,17 @@ RSpec.describe ActiveRecord::SaferMigrations::Migration do
9
11
  end
10
12
  end
11
13
 
12
- before { nuke_migrations }
13
- before { TimeoutTestHelpers.set(:lock_timeout, 0) }
14
- before { TimeoutTestHelpers.set(:statement_timeout, 0) }
14
+ before do
15
+ nuke_migrations
16
+ TimeoutTestHelpers.set(:lock_timeout, 0)
17
+ TimeoutTestHelpers.set(:statement_timeout, 0)
18
+ end
15
19
 
16
20
  describe "setting timeouts explicitly" do
17
- before { $lock_timeout = nil }
18
- before { $statement_timeout = nil }
21
+ before do
22
+ $lock_timeout = nil
23
+ $statement_timeout = nil
24
+ end
19
25
 
20
26
  shared_examples_for "running the migration" do
21
27
  let(:migration) do
@@ -51,8 +57,10 @@ RSpec.describe ActiveRecord::SaferMigrations::Migration do
51
57
  end
52
58
 
53
59
  context "when the original timeout is not 0" do
54
- before { TimeoutTestHelpers.set(:lock_timeout, 8000) }
55
- before { TimeoutTestHelpers.set(:statement_timeout, 8001) }
60
+ before do
61
+ TimeoutTestHelpers.set(:lock_timeout, 8000)
62
+ TimeoutTestHelpers.set(:statement_timeout, 8001)
63
+ end
56
64
 
57
65
  it "unsets the lock timeout after the migration" do
58
66
  silence_stream($stdout) { run_migration.call }
@@ -82,10 +90,13 @@ RSpec.describe ActiveRecord::SaferMigrations::Migration do
82
90
  end
83
91
 
84
92
  describe "the default timeouts" do
85
- before { $lock_timeout = nil }
86
- before { $statement_timeout = nil }
87
- before { ActiveRecord::SaferMigrations.default_lock_timeout = 6000 }
88
- before { ActiveRecord::SaferMigrations.default_statement_timeout = 6001 }
93
+ before do
94
+ $lock_timeout = nil
95
+ $statement_timeout = nil
96
+ ActiveRecord::SaferMigrations.default_lock_timeout = 6000
97
+ ActiveRecord::SaferMigrations.default_statement_timeout = 6001
98
+ end
99
+
89
100
  let(:migration) do
90
101
  Class.new(migration_base_class) do
91
102
  def change
@@ -117,10 +128,13 @@ RSpec.describe ActiveRecord::SaferMigrations::Migration do
117
128
  end
118
129
 
119
130
  describe "when inheriting from a migration with timeouts defined" do
120
- before { $lock_timeout = nil }
121
- before { $statement_timeout = nil }
122
- before { ActiveRecord::SaferMigrations.default_lock_timeout = 6000 }
123
- before { ActiveRecord::SaferMigrations.default_statement_timeout = 6001 }
131
+ before do
132
+ $lock_timeout = nil
133
+ $statement_timeout = nil
134
+ ActiveRecord::SaferMigrations.default_lock_timeout = 6000
135
+ ActiveRecord::SaferMigrations.default_statement_timeout = 6001
136
+ end
137
+
124
138
  let(:base_migration) do
125
139
  Class.new(migration_base_class) do
126
140
  set_lock_timeout(7000)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_record"
2
4
  require "activerecord-safer_migrations"
3
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-safer_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless Engineering
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-23 00:00:00.000000000 Z
11
+ date: 2020-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,66 +16,67 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '5.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '5.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pg
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.21.0
33
+ version: 1.2.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.21.0
40
+ version: 1.2.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.3.0
47
+ version: 3.9.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.3.0
54
+ version: 3.9.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.35.1
61
+ version: 0.92.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.35.1
68
+ version: 0.92.0
69
69
  description: ''
70
70
  email: developers@gocardless.com
71
71
  executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files: []
74
74
  files:
75
+ - ".circleci/config.yml"
75
76
  - ".gitignore"
76
77
  - ".rubocop.yml"
78
+ - ".rubocop_todo.yml"
77
79
  - ".ruby-version"
78
- - ".travis.yml"
79
80
  - CHANGELOG.md
80
81
  - Gemfile
81
82
  - LICENSE.txt
@@ -93,24 +94,23 @@ homepage: https://github.com/gocardless/activerecord-safer_migrations
93
94
  licenses:
94
95
  - MIT
95
96
  metadata: {}
96
- post_install_message:
97
+ post_install_message:
97
98
  rdoc_options: []
98
99
  require_paths:
99
100
  - lib
100
101
  required_ruby_version: !ruby/object:Gem::Requirement
101
102
  requirements:
102
- - - "~>"
103
+ - - ">="
103
104
  - !ruby/object:Gem::Version
104
- version: '2.2'
105
+ version: '2.5'
105
106
  required_rubygems_version: !ruby/object:Gem::Requirement
106
107
  requirements:
107
108
  - - ">="
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.6.11
113
- signing_key:
112
+ rubygems_version: 3.1.4
113
+ signing_key:
114
114
  specification_version: 4
115
115
  summary: ActiveRecord migration helpers to avoid downtime
116
116
  test_files: []
@@ -1,24 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.4.1
5
- - 2.3.4
6
- - 2.2.6
7
-
8
- addons:
9
- postgresql: "9.3"
10
-
11
- before_script:
12
- - psql -c 'CREATE DATABASE safer_migrations_test;' -U postgres
13
-
14
- script:
15
- - bundle exec rspec spec
16
- - bundle exec rubocop
17
-
18
- env:
19
- global:
20
- - "DATABASE_URL=postgres://postgres@localhost/safer_migrations_test"
21
- matrix:
22
- - "ACTIVERECORD_VERSION=4.2.9"
23
- - "ACTIVERECORD_VERSION=5.0.5"
24
- - "ACTIVERECORD_VERSION=5.1.3"