Your migration has access to a database connection in connection and the connection has an adapter_name method so you can just ask it what sort of connection it is:
def self.up
case connection.adapter_name
when 'PostgreSQL'
# Do PostgreSQL stuff
when 'MySQL'
# Do MySQL stuff
else
# Blow up and catch on fire. Or silently ignore it depending on your needs.
end
end
I'm not sure if I have the MySQL adapter name right but the technique is sound and you can easily check the MySQL adapter name yourself.