Skip to content

Commit 580bc8f

Browse files
committed
Add configuration to switch Departure database adapter version
1 parent 3a4eb44 commit 580bc8f

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,18 @@ It's strongly recommended to name it after this gems name, such as
151151

152152
All configuration options are configurable from the `Departure.configure` block example below
153153

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+
| db_adapter_name | nil | 'mysql2' or 'percona' - gives users an ability to provide the specific db adapter to override the db_adapter we use in departure see Db Adapter Support Below for details |
158+
159+
### Db Adapter Support
160+
161+
Starting in Rails 8.1 we add support for the use of the trilogy database adapter gem. Logic for selecting an adapter follows this logic
162+
163+
1. Departure.configuration.db_adapter_name is set to 'mysql2' or 'trilogy' use that value
164+
2. If the database configuration specifies 'mysql2 or 'trilogy' use that adapter
165+
3. Default to mysql2
157166

158167
### Disable on per-migration basis
159168

lib/departure/configuration.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
module Departure
22
class Configuration
33
attr_accessor :tmp_path, :global_percona_args, :enabled_by_default, :redirect_stderr,
4-
:disable_rails_advisory_lock_patch
4+
:disable_rails_advisory_lock_patch, :db_adapter_name
55

66
def initialize
77
@tmp_path = '.'.freeze
88
@error_log_filename = 'departure_error.log'.freeze
99
@global_percona_args = nil
1010
@enabled_by_default = true
1111
@redirect_stderr = true
12+
@db_adapter_name = nil
1213
end
1314

1415
def error_log_path

spec/departure/configuration_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
describe '#initialize' do
55
its(:tmp_path) { is_expected.to eq('.') }
66
its(:error_log_filename) { is_expected.to eq('departure_error.log') }
7+
its(:db_adapter_name) { is_expected.to be_nil }
8+
end
9+
10+
describe '#db_adapter_name=' do
11+
subject { described_class.new.tmp_path = 'trilogy' }
12+
it { is_expected.to eq('trilogy') }
713
end
814

915
describe '#tmp_path' do

0 commit comments

Comments
 (0)