ghost_adapter 0.4.2 → 0.5.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: b98dc5855519562f982afa2e73b0022a1189c56d2b462eea08070fc4b67b80b1
4
+ data.tar.gz: b00a22d2fb5c2e72f8d863a51e66ade75e79511c04cf0f70afebc3aa5fa5d890
5
5
  SHA512:
6
- metadata.gz: fa3a445e9552d8614eebf6b999edf490e33b7bfbb2f2ce12523932788c33c57eda730fafb0856f410dc1c871266a6b13b5db48b671c92fb6df18b5e06c81ae05
7
- data.tar.gz: f32b9d3949a62052cd0ba561c10b86cb064eb93f0f284915ed2e1c432e4b74e7f20322b8463e127826fcf87293b7754a4f0695ee6a063fa32da6c7cf4700eda5
6
+ metadata.gz: 58bfcb9d8dc770ed0568d2113370fc76978dadf7e13ce54e7fe8515f994328d0b1e38c214a428d4aa9d43e41c34b7b042212e59c7efd6eb84769a6e3fd7d4316
7
+ data.tar.gz: e4d18d03186582228664f3c47626fdaec83b65ef50dc96bdf056feaf2a20e7e51089be036b73740d3f68ac48e979508f398abf9ecb731c510f3721f5247fefa7
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).
@@ -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.5.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.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin C Roos
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-30 00:00:00.000000000 Z
11
+ date: 2023-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -182,7 +182,7 @@ metadata:
182
182
  homepage_uri: https://github.com/wetransfer/ghost_adapter
183
183
  source_code_uri: https://github.com/wetransfer/ghost_adapter
184
184
  rubygems_mfa_required: 'true'
185
- post_install_message:
185
+ post_install_message:
186
186
  rdoc_options: []
187
187
  require_paths:
188
188
  - lib
@@ -197,8 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
199
  requirements: []
200
- rubygems_version: 3.2.32
201
- signing_key:
200
+ rubygems_version: 3.1.6
201
+ signing_key:
202
202
  specification_version: 4
203
203
  summary: Run ActiveRecord migrations through gh-ost
204
204
  test_files: []