@Nicolas One way to avoid this mistake is use getenv('CLOUDRON_MYSQL_USERNAME'), getenv('CLOUDRON_MYSQL_DATABASE') instead of the raw values. This way when you migrate next time, it will pick up the correct database connection values.
The full env list for MySQL is at https://cloudron.io/documentation/custom-apps/addons/#mysql