Created
January 15, 2014 14:25
-
-
Save danshultz/8437173 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module ActiveRecord | |
module ConnectionAdapters | |
class Mysql2Adapter | |
alias :build_table_structure :structure_dump | |
def structure_dump | |
build_table_structure << build_view_structure << build_function_structure | |
end | |
def build_function_structure | |
# generate sql here | |
end | |
def build_view_structure | |
sql = "SHOW FULL TABLES WHERE Table_type = 'VIEW'" | |
select_all(sql).inject("") do |structure, table| | |
table.delete('Table_type') | |
structure += select_one("SHOW CREATE VIEW #{quote_table_name(table.to_a.first.last)}")["Create View"] + ";\n\n" | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment