Skip to content

pacx table defineMigrationStrategy

github-actions[bot] edited this page Jul 22, 2025 · 2 revisions

Builds the data migration strategy to populate all the tables contained in a given solution

Aliases

pacx table defmig

Usage

This command comes handy when you need to define the strategy to migrate data on a set of tables that are strictly tied together in a complex relationship graph.

Starting from a set of tables contained in a given solution (if specified, otherwise it will fallback on the default solution set for this environment via pacx solution setDefault), it builds a directed graph and navigates into the graph to untangle the relationship chains, in a recursive pattern.

The untangling approach has the following pattern:

  1. Repeat while the chart contains nodes
  2. Extract the 'leaf nodes' from the graph (a leaf is a node that has no outbound relations - no lookup columns)
  3. If found
    1. Each leaf node can be imported directly
    2. Remove the leaf nodes from the graph, and all the relations directed towards the leaf nodes
  4. If not found, and there are still nodes in the graph, it means we have a cycle (a cycle is a set of nodes that are mutually related to each other)
    1. Extract the 'cycles' from the graph
    2. If the cycle is just one, untangle the cycle
    3. If the cycles are more than one
    4. Extract any self-loop that is also self-contained (a self contained cycle is a cycle which nodes are related exclusively to other nodes of the cycle)
    5. If found, untangle those self-loops and return to bullet 1
    6. If not found
      1. Extract any self-contained cycle that is not a self-loop
      2. If found, untangle those self-contained cycles and return to bullet 1
      3. If not found, it means that there is a complex relationship graph that cannot be managed by the algorithm, and needs to be untangled manually
        1. The algorithm breaks with an error, and prints the loops that he was not able to untangle

When we say untangle the cycle it means that:

  1. if the cycle is a self-loop
    1. import the table records without the lookup colum
    2. the update the imported records setting the lookup column
    3. remove the table from the graph
  2. otherwise break the chain in any point, properly managing self-loops that can be present in specific nodes of the cycle
    1. once defined the breaking point, import the table without the lookup column
    2. move to the next table of the chain, and import that table fully
    3. repeat the process until all the tables in the chain are imported
    4. update the table imported in step 2.1 with lookup columns
    5. remove the tables from the graph

At the end of the execution, the command prints a sequence of commands that can be:

  • Full import on table 'table name'
  • Import table 'table name' without column(s) 'columns to ignore during the import'
  • Update table 'table name' to set column(s) 'columns to update'
xrm table defineMigrationStrategy --solution "my_solution_unique_name"
xrm table defmig --solution "my_solution_unique_name"

Use the --verbose (-v) argument to display additiona information about the sequence of operations used to build the migration strategy.

Arguments

Long Name Short Name Required? Description Default value Valid values
solution s N The name of the solution containing the entities to export. If not specified, the default solution is used instead. - String
include-security-tables ist N If false, the security tables (organization, systemuser, businessunit, team, position, fieldsecurityprofile) are not taken consideration in the export. False true, false
skip-missing-tables skip N If true, the command will not fail if some tables are missing in the solution. The missing tables will be skipped. False true, false
verbose v N If true, the command will output more information about the export process. False true, false

Command list

Clone this wiki locally