Exemple #1
0
        public void CreateOrUpdateDatabase()
        {
            using (var connection = new MySqlConnection($"Server={_serverAddress};{_authenticationString}"))
            {
                connection.Open();
                var exists = connection.Query($"SHOW DATABASES LIKE '{_databaseNamePattern}'").Any();

                if (exists)
                {
                    CurrentLogger.Log($"Using MySQL database {_databaseNamePattern}");
                }
                else
                {
                    CurrentLogger.Log($"Creating new MySQL database {_databaseNamePattern}");

                    CreateDatabase(connection);
                    CreateTables(connection);
                }

                using (var t = connection.BeginTransaction())
                {
                    connection.Execute($"USE {_databaseNamePattern}");
                    Migrate(connection).Wait();
                    t.Commit();
                }
            }
        }
Exemple #2
0
 /// <inheritdoc />
 public void Log(string state, string message)
 {
     CurrentLogger?.Log(state, message);
 }