Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ end
to prevent accidental data loss. After successful or failed LHM migrations, these leftover
tables must be cleaned up.

**Note:** When developing locally or running tests, LHM runs 'inline' by default, meaning that the
extra table is not used and the original table is not replaced. If this behavior is not desirable
for your project, you can disable it by setting `Lhm.disallow_inline!` in the appropriate
environment file or initializer.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you think more explanation (of why it does that, or why you might want to opt out of it) is warranted here.


### Usage with ProxySQL
LHM can recover from connection loss. However, when used in conjunction with ProxySQL, there are multiple ways that
connection loss could induce data loss (if triggered by a failover). Therefore it will perform additional checks to
Expand Down Expand Up @@ -278,7 +283,7 @@ To run the tests:
```bash
bundle exec rake unit # unit tests
bundle exec rake integration # integration tests
bundle exec rake unit # all tests
bundle exec rake specs # all tests
```

You can run an individual test as follows:
Expand Down
12 changes: 12 additions & 0 deletions lib/lhm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ def self.logger
end
end

@@disallow_inline = false

# Use to control the inline-execution of Lhm migrations - by default migrations are inlined
# in test and development environments, and in some cases that's not desireable.
def self.disallow_inline!
@@disallow_inline = true
end

def self.inline_allowed?
!@@disallow_inline
end

private

def drop_tables_and_triggers(run = false, triggers, tables)
Expand Down
2 changes: 1 addition & 1 deletion lib/lhm/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Lhm
class Railtie < Rails::Railtie
initializer "lhm.test_setup" do
if Rails.env.test? || Rails.env.development?
Lhm.execute_inline!
Lhm.execute_inline! if Lhm.inline_allowed?
end
end
end
Expand Down