Created
June 1, 2012 11:16
-
-
Save corny/2851323 to your computer and use it in GitHub Desktop.
Hot fix that adds support for dumping triggers to the mysql2 adapter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/mysql2_dump_triggers.rb | |
module TriggerDumper | |
def structure_dump | |
super << select_all("SHOW TRIGGERS").map { |trigger| | |
exec_without_stmt("SHOW CREATE TRIGGER #{trigger['Trigger']}").first['SQL Original Statement'].sub(/DEFINER=\S+ /,'') << "\n\n" | |
}.join | |
end | |
end | |
ActiveRecord::ConnectionAdapters::Mysql2Adapter.send :include, TriggerDumper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment