Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Lhm.cleanup removes temporary triggers #51

Merged
merged 1 commit into from
Oct 2, 2013

Conversation

edmundsalvacion
Copy link
Contributor

In the event of a failed migration, triggers may not have been dropped
properly. To avoid errors, we must drop the lhm triggers before the lhm
tables.

lhm_tables.each do |table|
connection.execute("drop table #{table}")
end
true
else
puts "Existing LHM backup tables: #{lhm_tables.join(", ")}."
puts "Existing LHM backup tables: #{lhm_tables.join(", ")}." if lhm_tables.any?
puts "Existing LHM triggers: #{lhm_triggers.join(", ")}." if lhm_triggers.any?
puts "Run Lhm.cleanup(true) to drop them all."
Copy link

Choose a reason for hiding this comment

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

I'd suggest removing all the empty? checks in this method, they increase its complexity, and removing them leaves you with exactly one possible output. Also, in case both tables and triggers are empty, the "Run Lhm.cleanup ..." line is confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with the confusing parts of it.. especially when a cleanup is not necessary, a true is just given regardless of if its a dry run or not.

How would you feel about more informative output?

examples:

Existing LHM backup tables: 0
Existing LHM triggers: 0
Existing LHM backup tables: lhmn_users.. etc
Existing LHM triggers: lhmt_ins_users.. etc
Run Lhm.cleanup(true) to drop them all.

Or something of the sort?

@ghost
Copy link

ghost commented Sep 27, 2013

Looks good to me

@ghost
Copy link

ghost commented Sep 27, 2013

Oh and please update the readme section about this, at the moment it only mentions leftover tables, not triggers.

In the event of a failed migration, triggers may not have
been dropped properly. To avoid errors, we must drop
the lhm triggers before the lhm tables.
edmundsalvacion added a commit that referenced this pull request Oct 2, 2013
Ensure Lhm.cleanup removes temporary triggers
@edmundsalvacion edmundsalvacion merged commit 7615cc0 into master Oct 2, 2013
@edmundsalvacion edmundsalvacion deleted the cleanup_triggers branch October 2, 2013 09:56
@orien orien mentioned this pull request Jul 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant