ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Migrate Relationship Class

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Migrates an ObjectID-based relationship class to a GlobalID-based relationship class.

Usage

  • This tool will modify an existing relationship class which is ObjectID-based to a GlobalID-based relationship class to comply with runtime geodatabase requirements.

  • The origin feature class or table that participates in the Input Relationship Class must have a GlobalID field prior to using this tool. The destination class must also have a GlobalID field.

  • The existing input relationship class must be ObjectID based. The data may not be archive enabled.

  • This tool supports versioned and nonversioned data as input.

  • Feature-linked annotation relationship classes are not supported as input for this tool, as these relationships must remain ObjectID based.

  • It is recommended to have a backup copy of the data used as input for this tool.

Syntax

MigrateRelationshipClass_management (in_relationship_class)
ParameterExplanationData Type
in_relationship_class

ObjectID-based relationship class that will be migrated to a GlobalID-based relationship class. The origin and destination feature classes or tables must already have GlobalIDs.

Relationship Class

Code sample

MigrateRelationshipClass example 1 (Python window)

The following Python window script demonstrates how to use the MigrateRelationshipClass tool in immediate mode.

arcpy.MigrateRelationshipClass_management(r'C:\Data\Relationships.gdb\OneToMany')
MigrateRelationshipClass example 2 (stand-alone script)

The following script demonstrates how to use the MigrateRelationshipClass tool in a stand-alone script.

# Name: MigrateRelationshipClass_Example.py
# Description: Migrate an ObjectID-based relationship class to a GlobalID-based
#       relationship class. This script lists the ObjectID-based relationships classes
#       in a workspace, checks for GlobalIDs in the origin, then runs the tool

# Import system modules
import arcpy

# Set local variables
workspace = r'C:\Data\Relationships.gdb'

# List all of the relationship classes within the given workspace
rc_list = [c.name for c in arcpy.Describe(workspace).children if c.datatype == "RelationshipClass"]

# Build a list of relationship classes which have an OBJECTID based origin class key
rc_migrate = []
for rc in rc_list:
    rc_path = workspace + "\\" + rc
    rc_desc = arcpy.Describe(rc_path)
    for item in rc_desc.OriginClassKeys:
        if "OBJECTID" in item:
            rc_migrate.append(rc_path)

# Check that the origin feature classes have Global Ids
rc_final = []
for rel in rc_migrate:
    originfc = workspace + "\\" + arcpy.Describe(rel).originClassNames[0]
    if arcpy.ListFields(originfc,"","GlobalID"):
        rc_final.append(rel)
        print("Adding {0}  to the list to migrate. \n".format(rel.rsplit("\\",1)[1]))
    else:
        print("{0} must have Global Ids to migrate relationship class.\n".format(originfc.rsplit("\\",1)[1]))

# Pass the list of valid relationship classes into the Migrate Relationship tool
print("Passing valid relationship classes into the Migrate Relationship Class tool.\n")
for rel_class in rc_final:
    print("Migrating {0}... \n".format(rel_class.rsplit("\\",1)[1]))
    arcpy.MigrateRelationshipClass_management(rel_class)
    print(arcpy.GetMessages() + "\n")

Environments

  • Current Workspace

Licensing information

  • ArcGIS for Desktop Basic: No
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Relationship Classes toolset
  • RelationshipClass properties

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal