diff --git a/lib/brancher/database_rename_service.rb b/lib/brancher/database_rename_service.rb
index <HASH>..<HASH> 100644
--- a/lib/brancher/database_rename_service.rb
+++ b/lib/brancher/database_rename_service.rb
@@ -9,7 +9,7 @@ module Brancher
       database_extname = File.extname(configuration["database"])
       database_name = configuration["database"].gsub(%r{#{database_extname}$}) { "" }
       database_name += suffix unless database_name =~ %r{#{suffix}$}
-      configuration["database"] = database_name + database_extname
+      configuration["database"] = cap_length(database_name + database_extname)
       configurations
     end
 
@@ -22,6 +22,12 @@ module Brancher
 
     private
 
+    def cap_length(database_full_name)
+      max_length = 63
+      database_full_name = database_full_name.slice(0,max_length-22) + [Digest::MD5.digest(database_full_name)].pack("m0").slice(0,22) if database_full_name.length > max_length
+      database_full_name
+    end
+
     def env
       Rails.env
     end
cap database name length

cap database name length to <I> characters, this conforms to mysql and postgres default limitations for name lengths.