public override void Create()
        {
            using (var masterConnection = _connection.CreateMasterConnection())
            {
                CreateCreateOperations().ExecuteNonQuery(masterConnection);

                ClearPool();
            }

            var postCreateOperations = CreatePostCreateOperations();

            postCreateOperations.ExecuteNonQuery(_connection);

            if (postCreateOperations.Any())
            {
                // The post-creation operations may have create new types (e.g. extension),
                // reload type definitions
                _connection.Open();
                try
                {
                    ((NpgsqlConnection)_connection.DbConnection).ReloadTypes();
                }
                finally
                {
                    _connection.Close();
                }
            }
        }
예제 #2
0
        public override void Create()
        {
            using (var masterConnection = _connection.CreateMasterConnection())
            {
                MigrationCommandExecutor
                .ExecuteNonQuery(CreateCreateOperations(), masterConnection);

                ClearPool();
            }
        }
        public override void Create()
        {
            using (var masterConnection = _connection.CreateMasterConnection())
            {
                try
                {
                    MigrationCommandExecutor
                    .ExecuteNonQuery(CreateCreateOperations(), masterConnection);
                }
                catch (PostgresException e) when(
                    e.SqlState == "23505" && e.TableName == "pg_database_datname_index"
                    )
                {
                    // This occurs when two connections are trying to create the same database concurrently
                    // (happens in the tests). Simply ignore the error.
                }

                ClearPool();
            }
        }