Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade schema is failing to upgrade a new database. #6

Closed
rajrku opened this issue Feb 25, 2020 · 3 comments
Closed

Upgrade schema is failing to upgrade a new database. #6

rajrku opened this issue Feb 25, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@rajrku
Copy link

rajrku commented Feb 25, 2020

Fails to retrieve the schema name from the connection string when there is an extra space in the connection string - From Azure Portal the Connection strings have an extra space among the parts.

Potential fix is in the foreach loop where the token is trimmed any extra spaces.

File: src\dbup-mysql\MySqlExtensions.cs

public static class MySqlExtensions
{
    /// <summary>
    /// Creates an upgrader for MySql databases.
    /// </summary>
    /// <param name="supported">Fluent helper type.</param>
    /// <param name="connectionString">MySql database connection string.</param>
    /// <returns>
    /// A builder for a database upgrader designed for MySql databases.
    /// </returns>
    public static UpgradeEngineBuilder MySqlDatabase(this SupportedDatabases supported, string connectionString)
    {
        foreach (var pair in connectionString.Split(';').Select(s => s.Split('=')).Where(pair => pair.Length == 2).Where(pair => pair[0].Trim().ToLower() == "database"))
        {
            return MySqlDatabase(new MySqlConnectionManager(connectionString), pair[1]);
        }

        return MySqlDatabase(new MySqlConnectionManager(connectionString));
    }
@rajrku rajrku added the bug Something isn't working label Feb 25, 2020
@AdrianJSClark
Copy link
Member

Just for clarity, the code above is here: https://github.com/DbUp/DbUp/blob/d7170c5118c07a0adb2a47d9bef65dfb9008a46c/src/dbup-mysql/MySqlExtensions.cs#L27

That code makes me very uneasy. We should be using the appropriate connection string builder for MySQL rather than parsing the value ourselves.

I believe the class is MySqlConnectionStringBuilder (according to https://dev.mysql.com/doc/connector-net/en/connector-net-ref-mysqlclient.html after some quick searching).

@mjauernig
Copy link
Member

See also #5

@droyad droyad transferred this issue from DbUp/DbUp Jan 30, 2024
@droyad
Copy link
Member

droyad commented Jul 29, 2024

Duplicate of #5

@droyad droyad marked this as a duplicate of #5 Jul 29, 2024
@droyad droyad closed this as completed Jul 29, 2024
@github-project-automation github-project-automation bot moved this from Bugs to Done in Issue sorting Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

4 participants