lib/db_structure_ext/mysql_dump_methods.rb
# dump mysql routines: procedures and functions
dump mysql routines: procedures and functions
dump mysql routines : procedures and functions
def routines_dump
      structure = ""
      return structure unless supports_routines?
      sql = "SELECT ROUTINE_TYPE as type, ROUTINE_NAME as name FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='#{current_database}'"
      select_all(sql).each do |row|
        structure << select_one("SHOW CREATE #{row['type']} #{row['name']}")["Create #{row['type'].capitalize}"]
        structure.gsub!(/^(CREATE).+(PROCEDURE|FUNCTION)/, '\1 \2')
        structure << ";\n\n"
      end
      structure
    end
def routines_dump structure = "" return structure unless supports_routines? sql = "SELECT ROUTINE_TYPE as type, ROUTINE_NAME as name FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='#{current_database}'" select_all ( sql ) . each do | row | structure << select_one ( "SHOW CREATE #{row['type']} #{row['name']}" ) [ "Create #{row['type'].capitalize}" ] structure . gsub! ( / ^(CREATE).+(PROCEDURE|FUNCTION) / , '\1 \2' ) structure << ";\n\n" end structure end
dump mysql routines: procedures and functions
dump mysql routines : procedures and functions