lib/demonz/common.rb in capistrano-demonz-0.0.17 vs lib/demonz/common.rb in capistrano-demonz-0.0.18

- old
+ new

@@ -60,12 +60,15 @@ try_sudo "printf \"#{release_history}\" > #{release_file}" end # Get the database name given an application and release name def get_db_name(application, release) - db_name = "#{application}__#{release}" - # Remove characters that may cause MySQL issues - db_name.downcase.gsub(/([\.\-\/])/, '_') + # Match possible db username (max 16 chars) and, + # remove characters that may cause MySQL issues + clean_application_name = application.downcase.gsub(/([\.\-\/])/, '').slice(0, 16) + clean_release_name = release.downcase.gsub(/([\.\-\/])/, '_') + + db_name = "#{clean_application_name}__#{clean_release_name}" end # Get the regex pattern to extract details from the mysql connection string def db_string_regex(type) "--#{type}='?([a-zA-Z0-9!@\#$%^&*-=+]+)'?\s"