ghost_adapter 0.4.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +10 -0
- data/README.md +10 -0
- data/ghost_adapter.gemspec +1 -1
- data/lib/active_record/connection_adapters/mysql2_ghost_adapter.rb +27 -14
- data/lib/ghost_adapter/version.rb +1 -1
- data/lib/ghost_adapter.rb +3 -3
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db6c7c5238b2a991b16d8f6ee88f1235a444140c5c63cc54642f24ba0e7ab676
|
4
|
+
data.tar.gz: 397e5378c2ea9c23037f30ed25a855bd851ab711988a9a5aac522bc7f8b95839
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72c3f9895504609bfb0f46bcee0545ddf2d6af5f88c07bd2fe0c678b6151c5a7198eeaa8e3f9823d4d66ad92c1b8a55d45fda648fde3a538ffca4ee62d52056c
|
7
|
+
data.tar.gz: a60ca3725c8ff4ffe3beef1670815991d2113b10c5a2af61b192f5586c2ee086611f98cfc605343b58eb91d829c59971426878033ca86685f5a6f2a584438573
|
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).
|
data/ghost_adapter.gemspec
CHANGED
@@ -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.
|
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.
|
22
|
-
dry_run = ENV
|
23
|
-
GhostAdapter::VersionChecker.validate_executable! unless ENV
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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,
|
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?
|
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.
|
47
|
-
env_val = ENV
|
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
|
+
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:
|
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.
|
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.
|
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.
|
201
|
+
rubygems_version: 3.4.6
|
201
202
|
signing_key:
|
202
203
|
specification_version: 4
|
203
204
|
summary: Run ActiveRecord migrations through gh-ost
|