1

I want to synchronize the schema of replica. The steps I am following is documented in ArcGIS Resources:

  1. Export the geodatabase_1 replica schema using Export Replica Schema (Data Management) tool.
  2. Compare the schema of geodatabase_1 and geodatabase_2 replica using Compare Replica Schema (Data Management)
  3. Import the compared schema (.xml) to geodatabase_2 replica using Import Replica Schema (Data Management)

Code sample to import is:

def import_schema(admin_sde, geodatabase_2, in_replica, schema):
    """import compared replica schema to geodatabase
    :param admin_sde: admin connection to disconnect users
    :param geodatabase_2: import schema to geodatabase
    :param in_replica: import schema for replica
    :param schema: schema xml
    """
    try:
        replica_list = arcpy.da.ListReplicas(geodatabase_2)
        replica_user = (user.name.split(".")[0] for user in replica_list
                        if user.name.split(".")[-1] == in_replica.split(".")[-1]).next()
        connected_users = [con_user for con_user in arcpy.ListUsers(admin_sde)
                           if con_user.ClientName != socket.gethostname()]
        log.info('Pausing user connection to geo-database: "{}"\n'.format(geodatabase_2))
        arcpy.AcceptConnections(admin_sde, False)
        log.info('Disconnecting users except for: "{}" and "SDE" from the geo-database: "{}"\n'.format(replica_user,
                                                                                                       geodatabase_2))
        for user in connected_users:
            arcpy.DisconnectUser(admin_sde, user.ID)
        log.info('Importing schema file to geo-database: "{0}" on replica: "{1}"\n'.format(geodatabase_2, in_replica))
        result = arcpy.ImportReplicaSchema_management(geodatabase_2, schema)
        return result
    except Exception as error:
        log.error(error)
    finally:
        log.info('Resuming geo-database: "{}"\n'.format(geodatabase_2))
        arcpy.AcceptConnections(admin_sde, True)

When I import the compared schema through python script, it adds the new fields to geodatabase_2 but do not delete the fields which are already been deleted in geodatabase_1. This leads to too many unwanted fields in the geodatabase_2 replica. While working on ArcMap (Distributed Geodatabase -> Import Schema Changes), it opens a Import Schema Changes Wizard where we can select the dropped fields and apply the schema changes to geodatabase_2. How to achieve this via python script? I want the same schema should reflect at geodatabase_2 replica after importing compared schema.

  • Facing the same issue. Does anybody has the answer. One more addition to it : How the domain owner plays role while performing schema sync? Im also getting an error for one replica saying - 'Existing Domain Owner does not match that of the updated domain owner' Looking for urgent solution!! – user71719 Apr 21 '16 at 12:41
  • Welcome to GIS:SE @Hemlata! Could you please ask this as a new question instead of posting it as an answer? You can always add a link to this post in your question for reference =) – Joseph Apr 21 '16 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.