ghost_adapter 0.4.2 → 0.6.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: d80bd988fa02baef1df1c337a4738a1b2066614b91781742c43f57083aed7b96
4
- data.tar.gz: 987a7418fd4cdb664dee43d44b030bbce58ab1e632b521b9aef5b9e066a668e0
3
+ metadata.gz: db6c7c5238b2a991b16d8f6ee88f1235a444140c5c63cc54642f24ba0e7ab676
4
+ data.tar.gz: 397e5378c2ea9c23037f30ed25a855bd851ab711988a9a5aac522bc7f8b95839
5
5
  SHA512:
6
- metadata.gz: fa3a445e9552d8614eebf6b999edf490e33b7bfbb2f2ce12523932788c33c57eda730fafb0856f410dc1c871266a6b13b5db48b671c92fb6df18b5e06c81ae05
7
- data.tar.gz: f32b9d3949a62052cd0ba561c10b86cb064eb93f0f284915ed2e1c432e4b74e7f20322b8463e127826fcf87293b7754a4f0695ee6a063fa32da6c7cf4700eda5
6
+ metadata.gz: 72c3f9895504609bfb0f46bcee0545ddf2d6af5f88c07bd2fe0c678b6151c5a7198eeaa8e3f9823d4d66ad92c1b8a55d45fda648fde3a538ffca4ee62d52056c
7
+ data.tar.gz: a60ca3725c8ff4ffe3beef1670815991d2113b10c5a2af61b192f5586c2ee086611f98cfc605343b58eb91d829c59971426878033ca86685f5a6f2a584438573
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ - package-ecosystem: github-actions
8
+ directory: /
9
+ schedule:
10
+ interval: weekly
data/README.md CHANGED
@@ -62,6 +62,16 @@ If you have used the rails generator, you can set the variable to a falsey value
62
62
  - "truthy" values: `[1, t, true, y, yes]`
63
63
  - "falsey" values: `[0, f, false, n, no]`
64
64
 
65
+ ### Running tests
66
+
67
+ To run the tests for all versions, run this script:
68
+
69
+ ``` shell
70
+ bin/test_all_versions
71
+ ```
72
+
73
+ Make sure to use the appropriate Ruby version! ActiveRecord <6.0 is not compatible with Ruby 3, so specs for those versions will only run successfully in a Ruby 2 environment.
74
+
65
75
  ## Contributing
66
76
 
67
77
  Bug reports and pull requests are welcome on GitHub at https://github.com/wetransfer/ghost_adapter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](./CODE_OF_CONDUCT.md).
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  end
24
24
  spec.require_paths = ['lib']
25
25
 
26
- spec.add_dependency 'activerecord', '>= 5', '<= 7.1'
26
+ spec.add_dependency 'activerecord', '>= 5', '<= 7.2'
27
27
  spec.add_dependency 'mysql2', '>= 0.4.0', '< 0.6.0'
28
28
 
29
29
  spec.add_development_dependency 'bump', '~> 0'
@@ -18,9 +18,9 @@ module ActiveRecord
18
18
  end
19
19
 
20
20
  client = Mysql2::Client.new(config)
21
- if GhostAdapter::Internal.ghost_migration_enabeld?
22
- dry_run = ENV['DRY_RUN'] == '1'
23
- GhostAdapter::VersionChecker.validate_executable! unless ENV['SKIP_GHOST_VERSION_CHECK'] == '1'
21
+ if GhostAdapter::Internal.ghost_migration_enabled?
22
+ dry_run = ENV.fetch('DRY_RUN', nil) == '1'
23
+ GhostAdapter::VersionChecker.validate_executable! unless ENV.fetch('SKIP_GHOST_VERSION_CHECK', nil) == '1'
24
24
  ConnectionAdapters::Mysql2GhostAdapter.new(client, logger, nil, config, dry_run: dry_run)
25
25
  else
26
26
  ConnectionAdapters::Mysql2Adapter.new(client, logger, nil, config)
@@ -42,16 +42,29 @@ module ActiveRecord
42
42
  @dry_run = dry_run
43
43
  end
44
44
 
45
- def execute(sql, name = nil)
46
- # Only ALTER TABLE statements are automatically skipped by gh-ost
47
- # We need to manually skip CREATE TABLE, DROP TABLE, and
48
- # INSERT/DELETE (to schema migrations) for dry runs
49
- return if dry_run && should_skip_for_dry_run?(sql)
50
-
51
- if (table, query = parse_sql(sql))
52
- GhostAdapter::Migrator.execute(table, query, database, dry_run)
53
- else
54
- super(sql, name)
45
+ if Gem.loaded_specs['activerecord'].version >= Gem::Version.new('7.0')
46
+ def execute(sql, name = nil, async: false)
47
+ # Only ALTER TABLE statements are automatically skipped by gh-ost
48
+ # We need to manually skip CREATE TABLE, DROP TABLE, and
49
+ # INSERT/DELETE (to schema migrations) for dry runs
50
+ return if dry_run && should_skip_for_dry_run?(sql)
51
+
52
+ if (table, query = parse_sql(sql))
53
+ GhostAdapter::Migrator.execute(table, query, database, dry_run)
54
+ else
55
+ super(sql, name, async: async)
56
+ end
57
+ end
58
+ else
59
+ def execute(sql, name = nil)
60
+ # See comment above -- some tables need to be skipped manually for dry runs
61
+ return if dry_run && should_skip_for_dry_run?(sql)
62
+
63
+ if (table, query = parse_sql(sql))
64
+ GhostAdapter::Migrator.execute(table, query, database, dry_run)
65
+ else
66
+ super(sql, name)
67
+ end
55
68
  end
56
69
  end
57
70
 
@@ -80,7 +93,7 @@ module ActiveRecord
80
93
  end
81
94
  else
82
95
  def add_index(table_name, column_name, options = {})
83
- index_name, index_type, index_columns, _index_options = add_index_options(table_name, column_name, options)
96
+ index_name, index_type, index_columns, _index_options = add_index_options(table_name, column_name, **options)
84
97
 
85
98
  sql = build_add_index_sql(
86
99
  table_name, index_columns, index_name,
@@ -1,3 +1,3 @@
1
1
  module GhostAdapter
2
- VERSION = '0.4.2'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
data/lib/ghost_adapter.rb CHANGED
@@ -5,7 +5,7 @@ require 'active_record/connection_adapters/mysql2_ghost_adapter'
5
5
 
6
6
  require 'ghost_adapter/config'
7
7
 
8
- require 'ghost_adapter/railtie' if defined? ::Rails::Railtie
8
+ require 'ghost_adapter/railtie' if defined? Rails::Railtie
9
9
 
10
10
  module GhostAdapter
11
11
  def self.config
@@ -43,8 +43,8 @@ module GhostAdapter
43
43
  @@ghost_migration_enabled = true # rubocop:disable Style/ClassVars
44
44
  end
45
45
 
46
- def self.ghost_migration_enabeld?
47
- env_val = ENV['GHOST_MIGRATE']&.downcase
46
+ def self.ghost_migration_enabled?
47
+ env_val = ENV.fetch('GHOST_MIGRATE', 'false').downcase
48
48
  return false if %w[0 n no f false].include?(env_val)
49
49
 
50
50
  !!@@ghost_migration_enabled || %w[1 y yes t true].include?(env_val)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghost_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin C Roos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-30 00:00:00.000000000 Z
11
+ date: 2024-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5'
20
20
  - - "<="
21
21
  - !ruby/object:Gem::Version
22
- version: '7.1'
22
+ version: '7.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '5'
30
30
  - - "<="
31
31
  - !ruby/object:Gem::Version
32
- version: '7.1'
32
+ version: '7.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: mysql2
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +144,7 @@ files:
144
144
  - ".github/ISSUE_TEMPLATE/bug_report.md"
145
145
  - ".github/ISSUE_TEMPLATE/feature_request.md"
146
146
  - ".github/PULL_REQUEST_TEMPLATE.md"
147
+ - ".github/dependabot.yml"
147
148
  - ".github/workflows/tests.yml"
148
149
  - ".gitignore"
149
150
  - ".rubocop.yml"
@@ -197,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
198
  - !ruby/object:Gem::Version
198
199
  version: '0'
199
200
  requirements: []
200
- rubygems_version: 3.2.32
201
+ rubygems_version: 3.4.6
201
202
  signing_key:
202
203
  specification_version: 4
203
204
  summary: Run ActiveRecord migrations through gh-ost