departure 8.0.0 → 8.2.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/workflows/test.yml +41 -2
- data/.pryrc +6 -6
- data/.standard.yml +9 -0
- data/AGENTS.md +77 -0
- data/Appraisals +11 -8
- data/CHANGELOG.md +16 -0
- data/Gemfile +8 -9
- data/Gemfile.lock +25 -11
- data/README.md +26 -4
- data/RELEASING.md +5 -4
- data/Rakefile +10 -10
- data/configuration.rb +3 -3
- data/departure.gemspec +26 -29
- data/gemfiles/rails_7_2.gemfile +2 -2
- data/gemfiles/rails_7_2.gemfile.lock +28 -11
- data/gemfiles/rails_8_0.gemfile +2 -2
- data/gemfiles/rails_8_0.gemfile.lock +28 -11
- data/gemfiles/rails_8_1.gemfile +3 -3
- data/gemfiles/rails_8_1.gemfile.lock +27 -11
- data/lib/active_record/connection_adapters/departure_adapter_behavior.rb +88 -0
- data/lib/active_record/connection_adapters/for_alter.rb +4 -10
- data/lib/active_record/connection_adapters/patch_connection_handling.rb +7 -6
- data/lib/active_record/connection_adapters/rails_7_2_departure_adapter.rb +17 -58
- data/lib/active_record/connection_adapters/rails_7_2_trilogy_adapter.rb +53 -0
- data/lib/active_record/connection_adapters/rails_8_0_departure_adapter.rb +26 -66
- data/lib/active_record/connection_adapters/rails_8_0_trilogy_adapter.rb +21 -0
- data/lib/active_record/connection_adapters/rails_8_1_mysql2_adapter.rb +23 -0
- data/lib/active_record/connection_adapters/rails_8_1_trilogy_adapter.rb +21 -0
- data/lib/departure/alter_argument.rb +6 -6
- data/lib/departure/cli_generator.rb +12 -12
- data/lib/departure/command.rb +1 -1
- data/lib/departure/configuration.rb +3 -3
- data/lib/departure/connection_details.rb +7 -7
- data/lib/departure/db_client.rb +5 -5
- data/lib/departure/dsn.rb +2 -2
- data/lib/departure/errors.rb +2 -2
- data/lib/departure/log_sanitizers/password_sanitizer.rb +1 -1
- data/lib/departure/logger.rb +2 -2
- data/lib/departure/migration.rb +40 -10
- data/lib/departure/option.rb +4 -4
- data/lib/departure/rails_adapter.rb +145 -85
- data/lib/departure/rails_patches/active_record_migrator_with_advisory_lock_patch.rb +2 -2
- data/lib/departure/railtie.rb +7 -5
- data/lib/departure/runner.rb +3 -3
- data/lib/departure/user_options.rb +1 -1
- data/lib/departure/version.rb +1 -1
- data/lib/departure.rb +21 -23
- data/lib/lhm/adapter.rb +12 -12
- data/lib/lhm/column_with_sql.rb +8 -8
- data/lib/lhm.rb +1 -1
- data/test_database.rb +10 -10
- metadata +12 -4
- data/.rubocop.yml +0 -66
- data/.rubocop_todo.yml +0 -238
- data/lib/active_record/connection_adapters/rails_8_1_departure_adapter.rb +0 -83
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16b6d5328d47d826da716cebd0dcb170afeb063b2686c28c3b23f187071b18bc
|
|
4
|
+
data.tar.gz: 686cc1e24416f318641f428c04608cfcfb680159ee665d0e1a1f9a1bcfdc896a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aba7570f774e38b49ad97a0606fb0dab4a9e64989df68713862915102f4e145603b36e2d0956191ce4181f9203e6f993aed1dfb0e577a83448003569959f7c81
|
|
7
|
+
data.tar.gz: d70f0f913f84913d86dea473480a221c1b489216c14b19eaf46990f665f2316f95233e25aa1fb14b5d33d942b97d42b0d411a412e222d7f55d252a829ecf758a
|
data/.github/workflows/test.yml
CHANGED
|
@@ -3,7 +3,7 @@ name: Test
|
|
|
3
3
|
on: [push, pull_request]
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
|
-
|
|
6
|
+
test_mysql:
|
|
7
7
|
strategy:
|
|
8
8
|
fail-fast: false
|
|
9
9
|
matrix:
|
|
@@ -36,6 +36,45 @@ jobs:
|
|
|
36
36
|
run: sudo systemctl start mysql.service
|
|
37
37
|
- run: bin/setup
|
|
38
38
|
- run: bundle exec rake
|
|
39
|
+
|
|
40
|
+
test_trilogy:
|
|
41
|
+
strategy:
|
|
42
|
+
fail-fast: false
|
|
43
|
+
matrix:
|
|
44
|
+
ruby:
|
|
45
|
+
- 3.2
|
|
46
|
+
- 3.3
|
|
47
|
+
- 3.4
|
|
48
|
+
gemfile:
|
|
49
|
+
- gemfiles/rails_7_2.gemfile
|
|
50
|
+
- gemfiles/rails_8_0.gemfile
|
|
51
|
+
- gemfiles/rails_8_1.gemfile
|
|
52
|
+
env:
|
|
53
|
+
DB_ADAPTER: "trilogy"
|
|
54
|
+
PERCONA_DB_USER: root
|
|
55
|
+
PERCONA_DB_PASSWORD: root
|
|
56
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
steps:
|
|
59
|
+
- uses: actions/checkout@v4
|
|
60
|
+
- uses: ruby/setup-ruby@v1
|
|
61
|
+
with:
|
|
62
|
+
ruby-version: ${{ matrix.ruby }}
|
|
63
|
+
bundler-cache: true
|
|
64
|
+
- name: "Add Percona GPG key"
|
|
65
|
+
run: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 9334A25F8507EFA5
|
|
66
|
+
- name: "Add Percona APT repository"
|
|
67
|
+
run: echo "deb http://repo.percona.com/apt `lsb_release -cs` main" | sudo tee -a /etc/apt/sources.list
|
|
68
|
+
- run: sudo apt-get update -qq
|
|
69
|
+
- run: sudo apt-get install percona-toolkit
|
|
70
|
+
- name: Start MySQL server
|
|
71
|
+
run: sudo systemctl start mysql.service
|
|
72
|
+
- name: Configure MySQL for Trilogy
|
|
73
|
+
run: |
|
|
74
|
+
sudo mysql -u root -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; FLUSH PRIVILEGES;"
|
|
75
|
+
- run: bin/setup
|
|
76
|
+
- run: bundle exec rake
|
|
77
|
+
|
|
39
78
|
lint:
|
|
40
79
|
strategy:
|
|
41
80
|
fail-fast: false
|
|
@@ -50,4 +89,4 @@ jobs:
|
|
|
50
89
|
with:
|
|
51
90
|
ruby-version: 3.4
|
|
52
91
|
bundler-cache: true
|
|
53
|
-
- run: bundle exec
|
|
92
|
+
- run: bundle exec standardrb
|
data/.pryrc
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
if defined?(PryByebug)
|
|
2
|
-
Pry.commands.alias_command
|
|
3
|
-
Pry.commands.alias_command
|
|
4
|
-
Pry.commands.alias_command
|
|
5
|
-
Pry.commands.alias_command
|
|
6
|
-
Pry.commands.alias_command
|
|
2
|
+
Pry.commands.alias_command "c", "continue"
|
|
3
|
+
Pry.commands.alias_command "s", "step"
|
|
4
|
+
Pry.commands.alias_command "n", "next"
|
|
5
|
+
Pry.commands.alias_command "f", "finish"
|
|
6
|
+
Pry.commands.alias_command "w", "pry-backtrace"
|
|
7
7
|
|
|
8
|
-
Pry::Commands.command(/^$/,
|
|
8
|
+
Pry::Commands.command(/^$/, "repeat last command") do
|
|
9
9
|
pry_instance.run_command Pry.history.to_a.last
|
|
10
10
|
end
|
|
11
11
|
end
|
data/.standard.yml
ADDED
data/AGENTS.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Context
|
|
2
|
+
|
|
3
|
+
Departure is a Ruby gem that wraps Rails ActiveRecord migrations using `ALTER TABLE` statements with `pt-online-schema-change` (Percona Toolkit) so DDL runs online and non-blocking.
|
|
4
|
+
|
|
5
|
+
It must stay aware of how the ActiveRecord API changes across versions and supports all currently supported versions of Rails and Ruby.
|
|
6
|
+
|
|
7
|
+
It supports both the `mysql2` and `trilogy` database adapter gems (trilogy on Rails 7.2+).
|
|
8
|
+
|
|
9
|
+
# Project Layout
|
|
10
|
+
|
|
11
|
+
- `lib/active_record/connection_adapters/` — per-Rails-version connection adapters:
|
|
12
|
+
- `rails_7_2_departure_adapter.rb`
|
|
13
|
+
- `rails_7_2_trilogy_adapter.rb`
|
|
14
|
+
- `rails_8_0_departure_adapter.rb`
|
|
15
|
+
- `rails_8_0_trilogy_adapter.rb`
|
|
16
|
+
- `rails_8_1_mysql2_adapter.rb`
|
|
17
|
+
- `rails_8_1_trilogy_adapter.rb`
|
|
18
|
+
- `departure_adapter_behavior.rb`, `for_alter.rb`, `patch_connection_handling.rb` — shared behavior. `DepartureAdapterBehavior` holds the composable pieces (SchemaStatements, DbClientConnection, PerformQuery, and the Rails8 composite for Rails >= 8.0 adapters); new adapters should reuse these instead of redefining schema statements or client wrapping.
|
|
19
|
+
- `lib/departure/rails_adapter.rb` — version dispatch. `Departure::RailsAdapter.for(ar_version, db_connection_adapter:)` selects the right adapter class. New Rails/adapter combinations are wired in here.
|
|
20
|
+
- `lib/departure/railtie.rb` — Rails integration entry point; calls `RailsAdapter.register_integrations`.
|
|
21
|
+
- `lib/departure/runner.rb`, `cli_generator.rb`, `command.rb` — intercept ALTER statements and shell out to `pt-online-schema-change`.
|
|
22
|
+
- `lib/departure/rails_patches/` — targeted patches against ActiveRecord internals.
|
|
23
|
+
- `lib/lhm/` — LHM DSL compatibility shim.
|
|
24
|
+
- `spec/dummy/` — minimal Rails app used by integration specs.
|
|
25
|
+
|
|
26
|
+
# Adapter Selection
|
|
27
|
+
|
|
28
|
+
1. If the database config specifies `trilogy` (Rails 7.2+), use the trilogy adapter.
|
|
29
|
+
2. Otherwise default to `mysql2`.
|
|
30
|
+
|
|
31
|
+
Selection lives in `Departure::RailsAdapter.for`. When adding a new Rails version, add a `V<MAJOR>_<MINOR>_*Adapter` subclass of `BaseAdapter` declaring its mysql2/trilogy `Registration`s and add the version to the dispatch table in `.for`.
|
|
32
|
+
|
|
33
|
+
# Development
|
|
34
|
+
|
|
35
|
+
- `docker-compose.yml` brings up a MySQL database container and a Rails container with the gem mounted in.
|
|
36
|
+
- The `Appraisal` gem manages Rails version dependencies; configurations live in `Appraisals` and generated gemfiles in `gemfiles/`.
|
|
37
|
+
- Local gems are vendored to `tmp/local_gems` (mounted at `/app/vendor/bundle`) so debugging tools like `pry` can step through ActiveRecord internals.
|
|
38
|
+
|
|
39
|
+
## Required env vars
|
|
40
|
+
Set by `docker-compose.yml`; if running outside Docker, export them yourself:
|
|
41
|
+
|
|
42
|
+
- `PERCONA_DB_USER`
|
|
43
|
+
- `PERCONA_DB_PASSWORD`
|
|
44
|
+
- `PERCONA_DB_HOST`
|
|
45
|
+
- `PERCONA_DB_NAME`
|
|
46
|
+
- `DB_ADAPTER=trilogy` — only when running against trilogy
|
|
47
|
+
|
|
48
|
+
## External dependencies
|
|
49
|
+
|
|
50
|
+
- `pt-online-schema-change` from Percona Toolkit must be on `PATH` — the gem shells out to it. CI installs it from the Percona APT repo.
|
|
51
|
+
- MySQL server. Trilogy requires `mysql_native_password` auth, not `caching_sha2_password`. CI runs `ALTER USER ... IDENTIFIED WITH mysql_native_password` followed by `FLUSH PRIVILEGES` before the trilogy job.
|
|
52
|
+
|
|
53
|
+
# Testing
|
|
54
|
+
|
|
55
|
+
- Be sure that changes are valid against both `rubocop` and the `rspec` suites.
|
|
56
|
+
- The supported test matrix is defined in `.github/workflows/test.yml`:
|
|
57
|
+
- **mysql2:** Ruby 3.2 / 3.3 / 3.4 × Rails 7.2 / 8.0 / 8.1
|
|
58
|
+
- **trilogy:** Ruby 3.2 / 3.3 / 3.4 × Rails 7.2 / 8.0 / 8.1
|
|
59
|
+
- **lint:** Ruby 3.4 with the Rails 8.1 gemfile
|
|
60
|
+
- Run inside Docker via `appraisal`:
|
|
61
|
+
- Full suite: `docker compose exec rails bundle exec appraisal rails-8-1 bundle exec rspec spec`
|
|
62
|
+
- Single example: `docker compose exec rails bundle exec appraisal rails-8-1 bundle exec rspec spec/path/to_spec.rb:LINE`
|
|
63
|
+
- Trilogy run: prepend `DB_ADAPTER=trilogy` to the rspec command
|
|
64
|
+
- Lint: `docker compose exec rails bundle exec appraisal rails-8-1 bundle exec rubocop --parallel`
|
|
65
|
+
|
|
66
|
+
# Adding a Rails version
|
|
67
|
+
|
|
68
|
+
1. Add an `appraise '<rails-x-y>' do ... end` block in `Appraisals`.
|
|
69
|
+
2. `bundle exec appraisal generate && bundle exec appraisal install`
|
|
70
|
+
3. Add a matching `V<X>_<Y>_*Adapter` class in `lib/departure/rails_adapter.rb` and a connection-adapter file under `lib/active_record/connection_adapters/`.
|
|
71
|
+
4. Update the `gemfile:` matrix in `.github/workflows/test.yml`. Add a separate `test_trilogy` entry only if trilogy is supported on that version.
|
|
72
|
+
|
|
73
|
+
# Conventions
|
|
74
|
+
|
|
75
|
+
- Follow the existing adapter naming pattern: `rails_<MAJOR>_<MINOR>_<DRIVER>_adapter.rb` and register through `Departure::RailsAdapter`. Don't introduce a parallel registration path.
|
|
76
|
+
- User-visible changes go in `CHANGELOG.md` (Keep a Changelog format).
|
|
77
|
+
- Release process is documented in `RELEASING.md`.
|
data/Appraisals
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
appraise
|
|
2
|
-
gem
|
|
3
|
-
gem
|
|
1
|
+
appraise "rails-7-2" do
|
|
2
|
+
gem "bigdecimal"
|
|
3
|
+
gem "rails", "7.2.2.1"
|
|
4
|
+
gem "trilogy"
|
|
4
5
|
end
|
|
5
6
|
|
|
6
|
-
appraise
|
|
7
|
-
gem
|
|
8
|
-
gem
|
|
7
|
+
appraise "rails-8-0" do
|
|
8
|
+
gem "bigdecimal"
|
|
9
|
+
gem "rails", "8.0.2.1"
|
|
10
|
+
gem "trilogy"
|
|
9
11
|
end
|
|
10
12
|
|
|
11
|
-
appraise
|
|
12
|
-
gem
|
|
13
|
+
appraise "rails-8-1" do
|
|
14
|
+
gem "rails", "8.1.1"
|
|
15
|
+
gem "trilogy"
|
|
13
16
|
end
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,22 @@ Please follow the format in [Keep a Changelog](http://keepachangelog.com/)
|
|
|
6
6
|
|
|
7
7
|
## [NEXT]
|
|
8
8
|
|
|
9
|
+
## [8.2.0] - 2026-09-09
|
|
10
|
+
|
|
11
|
+
- [Add Rails 7.2 and 8.0 Trilogy adapter support](https://github.com/departurerb/departure/pull/145)
|
|
12
|
+
|
|
13
|
+
## [8.1.0] - 2026-05-28
|
|
14
|
+
|
|
15
|
+
- [Add Rails 8.1 Trilogy adapter support](https://github.com/departurerb/departure/pull/132)
|
|
16
|
+
|
|
17
|
+
## [8.0.2] - 2026-04-30
|
|
18
|
+
|
|
19
|
+
- [Fix Rails multi-database migrations](https://github.com/departurerb/departure/pull/138)
|
|
20
|
+
|
|
21
|
+
## [8.0.1] - 2025-12-12
|
|
22
|
+
|
|
23
|
+
- [Remove stderr message "Including for_alter statements"](https://github.com/departurerb/departure/pull/136)
|
|
24
|
+
|
|
9
25
|
## [8.0.0] - 2025-11-24
|
|
10
26
|
|
|
11
27
|
- Bump [appraisal to 2.5.0](https://github.com/departurerb/departure/pull/129)
|
data/Gemfile
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
source
|
|
1
|
+
source "https://rubygems.org"
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
gem
|
|
6
|
-
gem
|
|
7
|
-
gem
|
|
8
|
-
gem
|
|
9
|
-
gem
|
|
10
|
-
gem
|
|
11
|
-
gem
|
|
12
|
-
gem 'zeitwerk', '< 2.7.0'
|
|
5
|
+
gem "base64"
|
|
6
|
+
gem "codeclimate-test-reporter", "~> 1.0.3", group: :test, require: nil
|
|
7
|
+
gem "lhm"
|
|
8
|
+
gem "logger"
|
|
9
|
+
gem "mutex_m", require: false
|
|
10
|
+
gem "standardrb", require: false
|
|
11
|
+
gem "zeitwerk", "< 2.7.0"
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
departure (8.
|
|
4
|
+
departure (8.2.0)
|
|
5
5
|
activerecord (>= 7.2.0)
|
|
6
6
|
mysql2 (>= 0.4.0, < 0.6.0)
|
|
7
7
|
railties (>= 7.2.0)
|
|
@@ -99,7 +99,7 @@ GEM
|
|
|
99
99
|
pp (0.6.2)
|
|
100
100
|
prettyprint
|
|
101
101
|
prettyprint (0.2.0)
|
|
102
|
-
prism (1.
|
|
102
|
+
prism (1.9.0)
|
|
103
103
|
pry (0.15.2)
|
|
104
104
|
coderay (~> 1.1)
|
|
105
105
|
method_source (~> 1.0)
|
|
@@ -156,7 +156,7 @@ GEM
|
|
|
156
156
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
157
157
|
rspec-support (~> 3.13.0)
|
|
158
158
|
rspec-support (3.13.2)
|
|
159
|
-
rubocop (1.
|
|
159
|
+
rubocop (1.84.2)
|
|
160
160
|
json (~> 2.3)
|
|
161
161
|
language_server-protocol (~> 3.17.0.2)
|
|
162
162
|
lint_roller (~> 1.1.0)
|
|
@@ -164,15 +164,16 @@ GEM
|
|
|
164
164
|
parser (>= 3.3.0.2)
|
|
165
165
|
rainbow (>= 2.2.2, < 4.0)
|
|
166
166
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
167
|
-
rubocop-ast (>= 1.
|
|
167
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
168
168
|
ruby-progressbar (~> 1.7)
|
|
169
169
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
170
|
-
rubocop-ast (1.
|
|
170
|
+
rubocop-ast (1.49.1)
|
|
171
171
|
parser (>= 3.3.7.2)
|
|
172
|
-
prism (~> 1.
|
|
173
|
-
rubocop-performance (1.
|
|
174
|
-
|
|
175
|
-
rubocop
|
|
172
|
+
prism (~> 1.7)
|
|
173
|
+
rubocop-performance (1.26.1)
|
|
174
|
+
lint_roller (~> 1.1)
|
|
175
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
176
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
176
177
|
ruby-progressbar (1.13.0)
|
|
177
178
|
securerandom (0.4.1)
|
|
178
179
|
simplecov (0.13.0)
|
|
@@ -180,6 +181,20 @@ GEM
|
|
|
180
181
|
json (>= 1.8, < 3)
|
|
181
182
|
simplecov-html (~> 0.10.0)
|
|
182
183
|
simplecov-html (0.10.2)
|
|
184
|
+
standard (1.54.0)
|
|
185
|
+
language_server-protocol (~> 3.17.0.2)
|
|
186
|
+
lint_roller (~> 1.0)
|
|
187
|
+
rubocop (~> 1.84.0)
|
|
188
|
+
standard-custom (~> 1.0.0)
|
|
189
|
+
standard-performance (~> 1.8)
|
|
190
|
+
standard-custom (1.0.2)
|
|
191
|
+
lint_roller (~> 1.0)
|
|
192
|
+
rubocop (~> 1.50)
|
|
193
|
+
standard-performance (1.9.0)
|
|
194
|
+
lint_roller (~> 1.1)
|
|
195
|
+
rubocop-performance (~> 1.26.0)
|
|
196
|
+
standardrb (1.0.1)
|
|
197
|
+
standard
|
|
183
198
|
stringio (3.1.6)
|
|
184
199
|
thor (1.3.2)
|
|
185
200
|
timeout (0.4.3)
|
|
@@ -213,8 +228,7 @@ DEPENDENCIES
|
|
|
213
228
|
rake (>= 10.0)
|
|
214
229
|
rspec (~> 3.4, >= 3.4.0)
|
|
215
230
|
rspec-its (~> 1.2)
|
|
216
|
-
|
|
217
|
-
rubocop-performance (~> 1.20.2)
|
|
231
|
+
standardrb
|
|
218
232
|
zeitwerk (< 2.7.0)
|
|
219
233
|
|
|
220
234
|
BUNDLED WITH
|
data/README.md
CHANGED
|
@@ -151,9 +151,16 @@ It's strongly recommended to name it after this gems name, such as
|
|
|
151
151
|
|
|
152
152
|
All configuration options are configurable from the `Departure.configure` block example below
|
|
153
153
|
|
|
154
|
-
|Option|Default|What it Controls|
|
|
155
|
-
|
|
156
|
-
|disable_rails_advisory_lock_patch|false|When truthy, disables a patch in at least rails 7.1 and 7.2 where rails throws ConcurrentMigrationErrors due to the inability to release the advisory lock in migrations|
|
|
154
|
+
| Option | Default | What it Controls |
|
|
155
|
+
|-----------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
156
|
+
| disable_rails_advisory_lock_patch | false | When truthy, disables a patch in at least rails 7.1 and 7.2 where rails throws ConcurrentMigrationErrors due to the inability to release the advisory lock in migrations |
|
|
157
|
+
|
|
158
|
+
### Trilogy Adapter Support
|
|
159
|
+
|
|
160
|
+
The trilogy database adapter gem is supported on Rails 7.2 and newer. Logic for selecting an adapter follows this logic
|
|
161
|
+
|
|
162
|
+
1. If the database configuration specifies 'trilogy' use the trilogy adapter
|
|
163
|
+
2. Default to mysql2
|
|
157
164
|
|
|
158
165
|
### Disable on per-migration basis
|
|
159
166
|
|
|
@@ -213,6 +220,21 @@ When any errors occur, an `ActiveRecord::StatementInvalid` exception is
|
|
|
213
220
|
raised and the migration is aborted, as all other ActiveRecord connection
|
|
214
221
|
adapters.
|
|
215
222
|
|
|
223
|
+
### Rails multi-database applications
|
|
224
|
+
|
|
225
|
+
Rails multi-database applications expect `bin/rails db:migrate` to run
|
|
226
|
+
migrations for every configured database. Rails 8.1 does this through
|
|
227
|
+
`ActiveRecord::Tasks::DatabaseTasks.migrate_all`, which temporarily switches the
|
|
228
|
+
migration connection to each database configuration before running that
|
|
229
|
+
database's migrations.
|
|
230
|
+
|
|
231
|
+
Departure supports that flow by restoring Rails' migration connection identity
|
|
232
|
+
after each migration. During the migration body, Departure can still reconnect
|
|
233
|
+
with the Percona adapter so `ALTER TABLE` statements go through
|
|
234
|
+
`pt-online-schema-change`. After the migration finishes, Rails gets back the
|
|
235
|
+
same `ActiveRecord::Base.connection_specification_name` it had before Departure
|
|
236
|
+
swapped adapters, so the next configured database can be migrated normally.
|
|
237
|
+
|
|
216
238
|
### Diagram
|
|
217
239
|
|
|
218
240
|
```mermaid
|
|
@@ -226,7 +248,7 @@ adapters.
|
|
|
226
248
|
%% Core Departure Components
|
|
227
249
|
subgraph "Departure System"
|
|
228
250
|
RailsAdapter["RailsAdapter<br/>(Version Detection)"]
|
|
229
|
-
DepartureAdapter["
|
|
251
|
+
DepartureAdapter["Rails81Mysql2Adapter<br/>(Connection Adapter)"]
|
|
230
252
|
Runner["Runner<br/>(Query Interceptor)"]
|
|
231
253
|
Command["Command<br/>(Process Executor)"]
|
|
232
254
|
CliGenerator["CliGenerator<br/>(Command Builder)"]
|
data/RELEASING.md
CHANGED
|
@@ -8,10 +8,11 @@ master, name it following the Rails repo convention, such as `v4.2`, and
|
|
|
8
8
|
we'll keep it open for bug fixes.
|
|
9
9
|
|
|
10
10
|
1. Update `lib/departure/version.rb` accordingly
|
|
11
|
-
2.
|
|
11
|
+
2. Run `bundle && bundle exec appraisal` to udpate the lock files
|
|
12
|
+
3. Review the `CHANGELOG.md` and add a new section following the format
|
|
12
13
|
`[version] - YYYY-MM-DD`. We conform to the guidelines of
|
|
13
14
|
http://keepachangelog.com/
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
4. Commit the changes with the message `Prepare release VERSION`
|
|
16
|
+
5. Execute the release rake task as `bundle exec rake release`. It creates the
|
|
16
17
|
tag, builds and pushes the gem to Rubygems.
|
|
17
|
-
|
|
18
|
+
6. Announce it! :tada:
|
data/Rakefile
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rspec/core/rake_task"
|
|
3
3
|
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
4
|
+
require "logger"
|
|
5
|
+
require "./configuration"
|
|
6
|
+
require "./test_database"
|
|
7
7
|
|
|
8
8
|
RSpec::Core::RakeTask.new(:spec)
|
|
9
9
|
|
|
10
10
|
task default: :spec
|
|
11
11
|
|
|
12
12
|
namespace :db do
|
|
13
|
-
desc
|
|
13
|
+
desc "Create the test database"
|
|
14
14
|
task :create do
|
|
15
15
|
config = Configuration.new
|
|
16
16
|
|
|
17
17
|
ActiveRecord::Base.establish_connection(
|
|
18
|
-
adapter:
|
|
19
|
-
host: config[
|
|
20
|
-
username: config[
|
|
21
|
-
password: config[
|
|
18
|
+
adapter: "mysql2",
|
|
19
|
+
host: config["hostname"],
|
|
20
|
+
username: config["username"],
|
|
21
|
+
password: config["password"]
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
TestDatabase.new(config).setup_test_database
|
data/configuration.rb
CHANGED
data/departure.gemspec
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
4
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
3
|
|
|
6
|
-
require
|
|
4
|
+
require "departure/version"
|
|
7
5
|
|
|
8
6
|
Gem::Specification.new do |spec|
|
|
9
|
-
spec.name
|
|
10
|
-
spec.version
|
|
11
|
-
spec.authors
|
|
12
|
-
spec.email
|
|
13
|
-
|
|
14
|
-
spec.
|
|
15
|
-
spec.
|
|
16
|
-
spec.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
spec.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
spec.add_runtime_dependency
|
|
25
|
-
spec.add_runtime_dependency
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
spec.add_development_dependency
|
|
29
|
-
spec.add_development_dependency
|
|
30
|
-
spec.add_development_dependency
|
|
31
|
-
spec.add_development_dependency
|
|
32
|
-
spec.add_development_dependency
|
|
33
|
-
spec.add_development_dependency 'climate_control', '~> 0.0.3'
|
|
7
|
+
spec.name = "departure"
|
|
8
|
+
spec.version = Departure::VERSION
|
|
9
|
+
spec.authors = ["Ilya Zayats", "Pau Pérez", "Fran Casas", "Jorge Morante", "Enrico Stano", "Adrian Serafin", "Kirk Haines", "Guillermo Iguaran", "Austin Story", "Douglas Soares de Andrade"]
|
|
10
|
+
spec.email = ["ilya.zayats@redbooth.com", "pau.perez@redbooth.com", "nflamel@gmail.com", "jorge.morante@redbooth.com", "adrian@softmad.pl", "wyhaines@gmail.com", "guilleiguaran@gmail.com", "lonnieastory@gmail.com", "douglas@51street.dev"]
|
|
11
|
+
spec.summary = "pt-online-schema-change runner for ActiveRecord migrations"
|
|
12
|
+
spec.description = "Execute your ActiveRecord migrations with Percona's pt-online-schema-change. Formerly known as Percona Migrator."
|
|
13
|
+
spec.homepage = "https://github.com/departurerb/departure"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
17
|
+
spec.require_paths = ["lib"]
|
|
18
|
+
|
|
19
|
+
spec.required_ruby_version = ">= 3.2.0"
|
|
20
|
+
|
|
21
|
+
spec.add_runtime_dependency "railties", ">= 7.2.0"
|
|
22
|
+
spec.add_runtime_dependency "activerecord", ">= 7.2.0"
|
|
23
|
+
spec.add_runtime_dependency "mysql2", ">= 0.4.0", "< 0.6.0"
|
|
24
|
+
|
|
25
|
+
spec.add_development_dependency "appraisal", "~> 2.5.0"
|
|
26
|
+
spec.add_development_dependency "rake", ">= 10.0"
|
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.4", ">= 3.4.0"
|
|
28
|
+
spec.add_development_dependency "rspec-its", "~> 1.2"
|
|
29
|
+
spec.add_development_dependency "pry-byebug"
|
|
30
|
+
spec.add_development_dependency "climate_control", "~> 0.0.3"
|
|
34
31
|
end
|
data/gemfiles/rails_7_2.gemfile
CHANGED
|
@@ -7,10 +7,10 @@ gem "codeclimate-test-reporter", "~> 1.0.3", group: :test, require: nil
|
|
|
7
7
|
gem "lhm"
|
|
8
8
|
gem "logger"
|
|
9
9
|
gem "mutex_m", require: false
|
|
10
|
-
gem "
|
|
11
|
-
gem "rubocop-performance", "~> 1.20.2", require: false
|
|
10
|
+
gem "standardrb", require: false
|
|
12
11
|
gem "zeitwerk", "< 2.7.0"
|
|
13
12
|
gem "bigdecimal"
|
|
14
13
|
gem "rails", "7.2.2.1"
|
|
14
|
+
gem "trilogy"
|
|
15
15
|
|
|
16
16
|
gemspec path: "../"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ..
|
|
3
3
|
specs:
|
|
4
|
-
departure (8.
|
|
4
|
+
departure (8.2.0)
|
|
5
5
|
activerecord (>= 7.2.0)
|
|
6
6
|
mysql2 (>= 0.4.0, < 0.6.0)
|
|
7
7
|
railties (>= 7.2.0)
|
|
@@ -167,7 +167,7 @@ GEM
|
|
|
167
167
|
pp (0.6.3)
|
|
168
168
|
prettyprint
|
|
169
169
|
prettyprint (0.2.0)
|
|
170
|
-
prism (1.
|
|
170
|
+
prism (1.9.0)
|
|
171
171
|
pry (0.15.2)
|
|
172
172
|
coderay (~> 1.1)
|
|
173
173
|
method_source (~> 1.0)
|
|
@@ -240,7 +240,7 @@ GEM
|
|
|
240
240
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
241
241
|
rspec-support (~> 3.13.0)
|
|
242
242
|
rspec-support (3.13.6)
|
|
243
|
-
rubocop (1.
|
|
243
|
+
rubocop (1.84.2)
|
|
244
244
|
json (~> 2.3)
|
|
245
245
|
language_server-protocol (~> 3.17.0.2)
|
|
246
246
|
lint_roller (~> 1.1.0)
|
|
@@ -248,15 +248,16 @@ GEM
|
|
|
248
248
|
parser (>= 3.3.0.2)
|
|
249
249
|
rainbow (>= 2.2.2, < 4.0)
|
|
250
250
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
251
|
-
rubocop-ast (>= 1.
|
|
251
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
252
252
|
ruby-progressbar (~> 1.7)
|
|
253
253
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
254
|
-
rubocop-ast (1.
|
|
254
|
+
rubocop-ast (1.49.1)
|
|
255
255
|
parser (>= 3.3.7.2)
|
|
256
|
-
prism (~> 1.
|
|
257
|
-
rubocop-performance (1.
|
|
258
|
-
|
|
259
|
-
rubocop
|
|
256
|
+
prism (~> 1.7)
|
|
257
|
+
rubocop-performance (1.26.1)
|
|
258
|
+
lint_roller (~> 1.1)
|
|
259
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
260
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
260
261
|
ruby-progressbar (1.13.0)
|
|
261
262
|
securerandom (0.4.1)
|
|
262
263
|
simplecov (0.13.0)
|
|
@@ -264,9 +265,25 @@ GEM
|
|
|
264
265
|
json (>= 1.8, < 3)
|
|
265
266
|
simplecov-html (~> 0.10.0)
|
|
266
267
|
simplecov-html (0.10.2)
|
|
268
|
+
standard (1.54.0)
|
|
269
|
+
language_server-protocol (~> 3.17.0.2)
|
|
270
|
+
lint_roller (~> 1.0)
|
|
271
|
+
rubocop (~> 1.84.0)
|
|
272
|
+
standard-custom (~> 1.0.0)
|
|
273
|
+
standard-performance (~> 1.8)
|
|
274
|
+
standard-custom (1.0.2)
|
|
275
|
+
lint_roller (~> 1.0)
|
|
276
|
+
rubocop (~> 1.50)
|
|
277
|
+
standard-performance (1.9.0)
|
|
278
|
+
lint_roller (~> 1.1)
|
|
279
|
+
rubocop-performance (~> 1.26.0)
|
|
280
|
+
standardrb (1.0.1)
|
|
281
|
+
standard
|
|
267
282
|
stringio (3.1.7)
|
|
268
283
|
thor (1.4.0)
|
|
269
284
|
timeout (0.4.4)
|
|
285
|
+
trilogy (2.12.6)
|
|
286
|
+
bigdecimal
|
|
270
287
|
tsort (0.2.0)
|
|
271
288
|
tzinfo (2.0.6)
|
|
272
289
|
concurrent-ruby (~> 1.0)
|
|
@@ -305,8 +322,8 @@ DEPENDENCIES
|
|
|
305
322
|
rake (>= 10.0)
|
|
306
323
|
rspec (~> 3.4, >= 3.4.0)
|
|
307
324
|
rspec-its (~> 1.2)
|
|
308
|
-
|
|
309
|
-
|
|
325
|
+
standardrb
|
|
326
|
+
trilogy
|
|
310
327
|
zeitwerk (< 2.7.0)
|
|
311
328
|
|
|
312
329
|
BUNDLED WITH
|
data/gemfiles/rails_8_0.gemfile
CHANGED
|
@@ -7,10 +7,10 @@ gem "codeclimate-test-reporter", "~> 1.0.3", group: :test, require: nil
|
|
|
7
7
|
gem "lhm"
|
|
8
8
|
gem "logger"
|
|
9
9
|
gem "mutex_m", require: false
|
|
10
|
-
gem "
|
|
11
|
-
gem "rubocop-performance", "~> 1.20.2", require: false
|
|
10
|
+
gem "standardrb", require: false
|
|
12
11
|
gem "zeitwerk", "< 2.7.0"
|
|
13
12
|
gem "bigdecimal"
|
|
14
13
|
gem "rails", "8.0.2.1"
|
|
14
|
+
gem "trilogy"
|
|
15
15
|
|
|
16
16
|
gemspec path: "../"
|