Ejemplo n.º 1
0
        private void Migrate(MyCatDatabaseHost node, string targetMigration = null)
        {
            var connection = _connection.CreateNodeConnection(node);

            _logger.LogDebug(RelationalStrings.UsingConnection(connection.DbConnection.Database, connection.DbConnection.DataSource));

            if (!_historyRepository.Exists(connection))
            {
                if (!_databaseCreator.Exists(connection))
                {
                    _databaseCreator.Create(node);
                }

                var command = _rawSqlCommandBuilder.Build(_historyRepository.GetCreateScript());

                command.ExecuteNonQuery(connection);
            }

            var commandLists = GetMigrationCommandLists(_historyRepository.GetAppliedMigrations(connection), targetMigration);

            foreach (var commandList in commandLists)
            {
                _migrationCommandExecutor.ExecuteNonQuery(commandList(), connection);
            }
            connection.Close();
            connection.Dispose();
        }
Ejemplo n.º 2
0
 public bool Exists(MyCatRelationalConnection conn)
 {
     return(_databaseCreator.Exists(conn) &&
            InterpretExistsResult(
                _rawSqlCommandBuilder.Build(ExistsSql).ExecuteScalar(conn)));
 }