ghost_adapter 0.0.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +29 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +5 -1
- data/.travis.yml +2 -2
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +28 -10
- data/README.md +4 -5
- data/Rakefile +3 -9
- data/ghost_adapter.gemspec +3 -1
- data/lib/active_record/connection_adapters/mysql2_ghost_adapter.rb +10 -2
- data/lib/ghost_adapter.rb +16 -1
- data/lib/ghost_adapter/config.rb +20 -12
- data/lib/ghost_adapter/env_parser.rb +4 -1
- data/lib/ghost_adapter/version.rb +1 -1
- data/lib/ghost_adapter/version_checker.rb +2 -0
- metadata +42 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cabaf83939ee711ed1679803274084bedf6598c2711d69bfeee19cb404a0add
|
4
|
+
data.tar.gz: e42e338f2c2afc2ea448fc9e14fb5132781b9afedcf1c097131e39a935efcb15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80eb4f5803734e3a599c165df1b22fa6892db6fd685d6aa59fc445a072376fad3e8e4fb8535dce94c44af9aced1ec34594a33270b4c0457b0826a11c8e9f6263
|
7
|
+
data.tar.gz: d2ef0fa71b5a429e1cddbe99c1432f047ac4842636f6cb58551416ff88f05d8a7d6ff3b1303c3a2769fb68aee95850b749f9b9831154f15bb2b4e66e2dba19a9
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [main]
|
6
|
+
pull_request:
|
7
|
+
branches: [main]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby-version: ["2.5", "2.6", "2.7", "3.0"]
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- name: Set up Ruby
|
19
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
20
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
21
|
+
# uses: ruby/setup-ruby@v1
|
22
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby-version }}
|
25
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
26
|
+
- name: Run rubocop
|
27
|
+
run: bundle exec rake rubocop
|
28
|
+
- name: Run tests
|
29
|
+
run: bundle exec rake spec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -9,13 +9,17 @@ Style/RescueModifier:
|
|
9
9
|
|
10
10
|
Metrics/BlockLength:
|
11
11
|
Exclude:
|
12
|
-
-
|
12
|
+
- spec/**/*_spec.rb
|
13
13
|
|
14
14
|
Metrics/MethodLength:
|
15
15
|
IgnoredMethods:
|
16
16
|
- build_ghost_command
|
17
17
|
- mysql2_ghost_connection
|
18
18
|
|
19
|
+
Metrics/ModuleLength:
|
20
|
+
Exclude:
|
21
|
+
- lib/ghost_adapter/config.rb
|
22
|
+
|
19
23
|
Metrics/AbcSize:
|
20
24
|
IgnoredMethods:
|
21
25
|
- build_ghost_command
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## 0.1.4
|
4
|
+
|
5
|
+
- Fix bug caused by missing `require 'open3'` that occurs for some ruby versions
|
6
|
+
|
7
|
+
## 0.1.3
|
8
|
+
|
9
|
+
- Fix bug [#26](https://github.com/WeTransfer/ghost_adapter/issues/26) causing environment configuration to be overwritten by some other configuration methods.
|
10
|
+
|
11
|
+
## 0.1.2
|
12
|
+
|
13
|
+
- Fix bug [#28](https://github.com/WeTransfer/ghost_adapter/issues/28) that resulted in add_index and remove_index calls to not run through `gh-ost`
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ghost_adapter (0.
|
4
|
+
ghost_adapter (0.1.4)
|
5
5
|
activerecord (>= 5)
|
6
|
+
mysql2 (>= 0.4.0, < 0.6.0)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
activemodel (6.1.1)
|
11
|
-
activesupport (= 6.1.1)
|
12
|
-
activerecord (6.1.1)
|
13
|
-
activemodel (= 6.1.1)
|
14
|
-
activesupport (= 6.1.1)
|
15
|
-
activesupport (6.1.1)
|
11
|
+
activemodel (6.1.3.1)
|
12
|
+
activesupport (= 6.1.3.1)
|
13
|
+
activerecord (6.1.3.1)
|
14
|
+
activemodel (= 6.1.3.1)
|
15
|
+
activesupport (= 6.1.3.1)
|
16
|
+
activesupport (6.1.3.1)
|
16
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
18
|
i18n (>= 1.6, < 2)
|
18
19
|
minitest (>= 5.1)
|
@@ -20,10 +21,13 @@ GEM
|
|
20
21
|
zeitwerk (~> 2.3)
|
21
22
|
ast (2.4.2)
|
22
23
|
bump (0.10.0)
|
24
|
+
byebug (11.1.3)
|
23
25
|
concurrent-ruby (1.1.8)
|
24
|
-
|
26
|
+
diff-lcs (1.4.4)
|
27
|
+
i18n (1.8.9)
|
25
28
|
concurrent-ruby (~> 1.0)
|
26
|
-
minitest (5.14.
|
29
|
+
minitest (5.14.4)
|
30
|
+
mysql2 (0.5.3)
|
27
31
|
parallel (1.20.1)
|
28
32
|
parser (3.0.0.0)
|
29
33
|
ast (~> 2.4.1)
|
@@ -31,6 +35,19 @@ GEM
|
|
31
35
|
rake (13.0.3)
|
32
36
|
regexp_parser (2.0.3)
|
33
37
|
rexml (3.2.4)
|
38
|
+
rspec (3.10.0)
|
39
|
+
rspec-core (~> 3.10.0)
|
40
|
+
rspec-expectations (~> 3.10.0)
|
41
|
+
rspec-mocks (~> 3.10.0)
|
42
|
+
rspec-core (3.10.1)
|
43
|
+
rspec-support (~> 3.10.0)
|
44
|
+
rspec-expectations (3.10.1)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.10.0)
|
47
|
+
rspec-mocks (3.10.2)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.10.0)
|
50
|
+
rspec-support (3.10.2)
|
34
51
|
rubocop (1.8.1)
|
35
52
|
parallel (~> 1.10)
|
36
53
|
parser (>= 3.0.0.0)
|
@@ -55,9 +72,10 @@ PLATFORMS
|
|
55
72
|
DEPENDENCIES
|
56
73
|
bump (~> 0)
|
57
74
|
bundler (~> 2)
|
75
|
+
byebug (~> 11.1)
|
58
76
|
ghost_adapter!
|
59
|
-
minitest (~> 5.14)
|
60
77
|
rake (~> 13.0)
|
78
|
+
rspec (~> 3)
|
61
79
|
rubocop (~> 1)
|
62
80
|
|
63
81
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
![ghost](./doc/images/ghost.png)
|
4
4
|
|
5
|
-
![
|
6
|
-
![
|
7
|
-
![Hippocratic License](https://img.shields.io/badge/license-Hippocratic-green
|
8
|
-
![gh-ost version](https://img.shields.io/badge/gh--ost%20version-1.1.0-blue
|
9
|
-
![depfu](https://img.shields.io/depfu/wetransfer/ghost_adapter)
|
5
|
+
[![Gem](https://img.shields.io/gem/v/ghost_adapter)](https://rubygems.org/gems/ghost_adapter)
|
6
|
+
[![Build Status](https://travis-ci.com/WeTransfer/ghost_adapter.svg?branch=main)](https://travis-ci.com/WeTransfer/ghost_adapter)
|
7
|
+
[![Hippocratic License](https://img.shields.io/badge/license-Hippocratic-green)](https://github.com/WeTransfer/ghost_adapter/blob/main/LICENSE.md)
|
8
|
+
[![gh-ost version](https://img.shields.io/badge/gh--ost%20version-1.1.0-blue)](https://github.com/github/gh-ost/releases/latest)
|
10
9
|
|
11
10
|
A tiny, _very configurable_ ActiveRecord adapter built for running [gh-ost](https://github.com/github/gh-ost) migrations. When not running migrations, it'll stay the heck out of the way.
|
12
11
|
|
data/Rakefile
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
-
require '
|
3
|
-
|
4
|
-
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs << 'test'
|
6
|
-
t.libs << 'lib'
|
7
|
-
t.test_files = FileList['test/**/*_test.rb']
|
8
|
-
end
|
9
|
-
|
2
|
+
require 'rspec/core/rake_task'
|
10
3
|
require 'rubocop/rake_task'
|
11
4
|
|
12
5
|
RuboCop::RakeTask.new
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
13
7
|
|
14
|
-
task default: %i[
|
8
|
+
task default: %i[spec rubocop]
|
data/ghost_adapter.gemspec
CHANGED
@@ -23,10 +23,12 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
25
|
spec.add_dependency 'activerecord', '>= 5'
|
26
|
+
spec.add_dependency 'mysql2', '>= 0.4.0', '< 0.6.0'
|
26
27
|
|
27
28
|
spec.add_development_dependency 'bump', '~> 0'
|
28
29
|
spec.add_development_dependency 'bundler', '~> 2'
|
29
|
-
spec.add_development_dependency '
|
30
|
+
spec.add_development_dependency 'byebug', '~> 11.1'
|
30
31
|
spec.add_development_dependency 'rake', '~> 13.0'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3'
|
31
33
|
spec.add_development_dependency 'rubocop', '~> 1'
|
32
34
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'active_record/connection_adapters/mysql2_adapter'
|
2
2
|
require 'ghost_adapter/migrator'
|
3
3
|
require 'ghost_adapter/version_checker'
|
4
|
-
|
5
|
-
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
|
6
4
|
require 'mysql2'
|
7
5
|
|
8
6
|
module ActiveRecord
|
@@ -56,6 +54,16 @@ module ActiveRecord
|
|
56
54
|
end
|
57
55
|
end
|
58
56
|
|
57
|
+
def add_index(table_name, column_name, options = {})
|
58
|
+
index_name, index_type, index_columns, index_options = add_index_options(table_name, column_name, options)
|
59
|
+
execute "ALTER TABLE #{quote_table_name(table_name)} ADD #{index_type} INDEX #{quote_column_name(index_name)} (#{index_columns})#{index_options}" # rubocop:disable Layout/LineLength
|
60
|
+
end
|
61
|
+
|
62
|
+
def remove_index(table_name, options = {})
|
63
|
+
index_name = index_name_for_remove(table_name, options)
|
64
|
+
execute "ALTER TABLE #{quote_table_name(table_name)} DROP INDEX #{quote_column_name(index_name)}"
|
65
|
+
end
|
66
|
+
|
59
67
|
private
|
60
68
|
|
61
69
|
attr_reader :database, :dry_run
|
data/lib/ghost_adapter.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'active_support/all'
|
3
|
+
|
4
|
+
require 'active_record/connection_adapters/mysql2_ghost_adapter'
|
5
|
+
|
1
6
|
require 'ghost_adapter/config'
|
2
7
|
|
3
8
|
require 'ghost_adapter/railtie' if defined? ::Rails::Railtie
|
@@ -8,11 +13,21 @@ module GhostAdapter
|
|
8
13
|
end
|
9
14
|
|
10
15
|
def self.setup(options = {})
|
11
|
-
|
16
|
+
new_config = GhostAdapter::Config.new(options)
|
17
|
+
|
18
|
+
if defined? @@config
|
19
|
+
@@config.merge!(new_config)
|
20
|
+
else
|
21
|
+
@@config = new_config # rubocop:disable Style/ClassVars
|
22
|
+
end
|
12
23
|
|
13
24
|
yield @@config if block_given?
|
14
25
|
end
|
15
26
|
|
27
|
+
def self.clear_config
|
28
|
+
@@config = GhostAdapter::Config.new # rubocop:disable Style/ClassVars
|
29
|
+
end
|
30
|
+
|
16
31
|
module Internal
|
17
32
|
@@ghost_migration_enabled = false # rubocop:disable Style/ClassVars
|
18
33
|
|
data/lib/ghost_adapter/config.rb
CHANGED
@@ -78,10 +78,14 @@ module GhostAdapter
|
|
78
78
|
user
|
79
79
|
verbose].freeze
|
80
80
|
Config = Struct.new(*CONFIG_KEYS, keyword_init: true) do
|
81
|
-
def
|
81
|
+
def merge!(other_config)
|
82
|
+
other_config.compact.each { |k, v| self[k] = v }
|
83
|
+
self
|
84
|
+
end
|
85
|
+
|
86
|
+
def with_env
|
82
87
|
env_config = EnvParser.new(ENV).config
|
83
|
-
|
84
|
-
super(config_options)
|
88
|
+
compact.merge(env_config)
|
85
89
|
end
|
86
90
|
|
87
91
|
def compact
|
@@ -89,16 +93,20 @@ module GhostAdapter
|
|
89
93
|
end
|
90
94
|
|
91
95
|
def as_args
|
92
|
-
|
93
|
-
|
96
|
+
with_env.map { |key, value| arg(key, value) }.compact
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def arg(key, value)
|
102
|
+
return unless value
|
94
103
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
end.compact
|
104
|
+
hyphenated_key = key.to_s.gsub('_', '-')
|
105
|
+
if value == true
|
106
|
+
"--#{hyphenated_key}"
|
107
|
+
else
|
108
|
+
"--#{hyphenated_key}=#{value}"
|
109
|
+
end
|
102
110
|
end
|
103
111
|
end
|
104
112
|
end
|
@@ -7,6 +7,9 @@ module GhostAdapter
|
|
7
7
|
next unless ghost_key?(key)
|
8
8
|
|
9
9
|
config_key = convert_env_key(key)
|
10
|
+
|
11
|
+
next unless GhostAdapter::CONFIG_KEYS.include?(config_key)
|
12
|
+
|
10
13
|
config_value = convert_env_value(value)
|
11
14
|
|
12
15
|
[config_key, config_value]
|
@@ -20,7 +23,7 @@ module GhostAdapter
|
|
20
23
|
end
|
21
24
|
|
22
25
|
def convert_env_key(key)
|
23
|
-
key.gsub('GHOST_', '').downcase
|
26
|
+
key.gsub('GHOST_', '').downcase.to_sym
|
24
27
|
end
|
25
28
|
|
26
29
|
def convert_env_value(value)
|
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.1.4
|
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: 2021-
|
11
|
+
date: 2021-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -24,6 +24,26 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mysql2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.0
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.6.0
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.4.0
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.6.0
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: bump
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,19 +73,19 @@ dependencies:
|
|
53
73
|
- !ruby/object:Gem::Version
|
54
74
|
version: '2'
|
55
75
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
76
|
+
name: byebug
|
57
77
|
requirement: !ruby/object:Gem::Requirement
|
58
78
|
requirements:
|
59
79
|
- - "~>"
|
60
80
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
81
|
+
version: '11.1'
|
62
82
|
type: :development
|
63
83
|
prerelease: false
|
64
84
|
version_requirements: !ruby/object:Gem::Requirement
|
65
85
|
requirements:
|
66
86
|
- - "~>"
|
67
87
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
88
|
+
version: '11.1'
|
69
89
|
- !ruby/object:Gem::Dependency
|
70
90
|
name: rake
|
71
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +100,20 @@ dependencies:
|
|
80
100
|
- - "~>"
|
81
101
|
- !ruby/object:Gem::Version
|
82
102
|
version: '13.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rspec
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '3'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '3'
|
83
117
|
- !ruby/object:Gem::Dependency
|
84
118
|
name: rubocop
|
85
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,10 +138,12 @@ files:
|
|
104
138
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
105
139
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
106
140
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
141
|
+
- ".github/workflows/ruby.yml"
|
107
142
|
- ".gitignore"
|
108
143
|
- ".rubocop.yml"
|
109
144
|
- ".travis.yml"
|
110
145
|
- ".vscode/settings.json"
|
146
|
+
- CHANGELOG.md
|
111
147
|
- CODEOWNERS
|
112
148
|
- CODE_OF_CONDUCT.md
|
113
149
|
- CONTRIBUTORS.md
|
@@ -151,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
187
|
- !ruby/object:Gem::Version
|
152
188
|
version: '0'
|
153
189
|
requirements: []
|
154
|
-
rubygems_version: 3.1.
|
190
|
+
rubygems_version: 3.1.4
|
155
191
|
signing_key:
|
156
192
|
specification_version: 4
|
157
193
|
summary: Run ActiveRecord migrations through gh-ost
|