---
title: "POST /v1/{+parent}/mappingRules"
method: POST
path: "/v1/{+parent}/mappingRules"
tags: ["projects"]
---

# POST /v1/{+parent}/mappingRules

`POST /v1/{+parent}/mappingRules`

Creates a new mapping rule for a given conversion workspace.

## Path parameters

- `parent` string, required

## Query parameters

- `mappingRuleId` string
- `requestId` string

## Request body

- MappingRule — Definition of a transformation that is to be applied to a group of entities in the source schema. Several such transformations can be applied to an entity sequentially to define the corresponding entity in the target schema.
  - `revisionCreateTime` string, google-datetime — Output only. The timestamp that the revision was created.
  - `entityMove` EntityMove — Options to configure rule type EntityMove. The rule is used to move an entity to a new schema. The rule filter field can refer to one or more entities. The rule scope can be one of: Table, Column, Constraint, Index, View, Function, Stored Procedure, Materialized View, Sequence, UDT
    - `newSchema` string — Required. The new schema
  - `ruleScope` 'DATABASE_ENTITY_TYPE_UNSPECIFIED' | 'DATABASE_ENTITY_TYPE_SCHEMA' | 'DATABASE_ENTITY_TYPE_TABLE' | 'DATABASE_ENTITY_TYPE_COLUMN' | 'DATABASE_ENTITY_TYPE_CONSTRAINT' | 'DATABASE_ENTITY_TYPE_INDEX' | 'DATABASE_ENTITY_TYPE_TRIGGER' | 'DATABASE_ENTITY_TYPE_VIEW' | 'DATABASE_ENTITY_TYPE_SEQUENCE' | 'DATABASE_ENTITY_TYPE_STORED_PROCEDURE' | 'DATABASE_ENTITY_TYPE_FUNCTION' | 'DATABASE_ENTITY_TYPE_SYNONYM' | 'DATABASE_ENTITY_TYPE_DATABASE_PACKAGE' | 'DATABASE_ENTITY_TYPE_UDT' | 'DATABASE_ENTITY_TYPE_MATERIALIZED_VIEW' | 'DATABASE_ENTITY_TYPE_DATABASE' — Required. The rule scope
  - `state` 'STATE_UNSPECIFIED' | 'ENABLED' | 'DISABLED' | 'DELETED' — Optional. The mapping rule state
  - `setTablePrimaryKey` SetTablePrimaryKey — Options to configure rule type SetTablePrimaryKey. The rule is used to specify the columns and name to configure/alter the primary key of a table. The rule filter field can refer to one entity. The rule scope can be one of: Table.
    - `primaryKeyColumns` string[] — Required. List of column names for the primary key
    - `primaryKey` string — Optional. Name for the primary key
  - `multiEntityRename` MultiEntityRename — Options to configure rule type MultiEntityRename. The rule is used to rename multiple entities. The rule filter field can refer to one or more entities. The rule scope can be one of: Database, Schema, Table, Column, Constraint, Index, View, Function, Stored Procedure, Materialized View, Sequence, UDT
    - `newNamePattern` string — Optional. The pattern used to generate the new entity's name. This pattern must include the characters '{name}', which will be replaced with the name of the original entity. For example, the pattern 't_{name}' for an entity name jobs would be converted to 't_jobs'. If unspecified, the default value for this field is '{name}'
    - `sourceNameTransformation` 'ENTITY_NAME_TRANSFORMATION_UNSPECIFIED' | 'ENTITY_NAME_TRANSFORMATION_NO_TRANSFORMATION' | 'ENTITY_NAME_TRANSFORMATION_LOWER_CASE' | 'ENTITY_NAME_TRANSFORMATION_UPPER_CASE' | 'ENTITY_NAME_TRANSFORMATION_CAPITALIZED_CASE' — Optional. Additional transformation that can be done on the source entity name before it is being used by the new_name_pattern, for example lower case. If no transformation is desired, use NO_TRANSFORMATION
  - `convertRowidColumn` ConvertRowIdToColumn — Options to configure rule type ConvertROWIDToColumn. The rule is used to add column rowid to destination tables based on an Oracle rowid function/property. The rule filter field can refer to one or more entities. The rule scope can be one of: Table. This rule requires additional filter to be specified beyond the basic rule filter field, which is whether or not to work on tables which already have a primary key defined.
    - `onlyIfNoPrimaryKey` boolean — Required. Only work on tables without primary key defined
  - `singlePackageChange` SinglePackageChange — Options to configure rule type SinglePackageChange. The rule is used to alter the sql code for a package entities. The rule filter field can refer to one entity. The rule scope can be: Package
    - `packageBody` string — Optional. Sql code for package body
    - `packageDescription` string — Optional. Sql code for package description
  - `ruleOrder` string, int64 — Required. The order in which the rule is applied. Lower order rules are applied before higher value rules so they may end up being overridden.
  - `sourceSqlChange` SourceSqlChange — Options to configure rule type SourceSqlChange. The rule is used to alter the sql code for database entities. The rule filter field can refer to one entity. The rule scope can be: StoredProcedure, Function, Trigger, View
    - `sqlCode` string — Required. Sql code for source (stored procedure, function, trigger or view)
  - `multiColumnDataTypeChange` MultiColumnDatatypeChange — Options to configure rule type MultiColumnDatatypeChange. The rule is used to change the data type and associated properties of multiple columns at once. The rule filter field can refer to one or more entities. The rule scope can be one of:Column. This rule requires additional filters to be specified beyond the basic rule filter field, which is the source data type, but the rule supports additional filtering capabilities such as the minimum and maximum field length. All additional filters which are specified are required to be met in order for the rule to be applied (logical AND between the fields).
    - `customFeatures` object — Optional. Custom engine specific features.
    - `sourceDataTypeFilter` string — Required. Filter on source data type.
    - `overrideFractionalSecondsPrecision` integer — Optional. Column fractional seconds precision - used only for timestamp based datatypes - if not specified and relevant uses the source column fractional seconds precision.
    - `sourceNumericFilter` SourceNumericFilter — Filter for fixed point number data types such as NUMERIC/NUMBER
      - `sourceMaxPrecisionFilter` integer — Optional. The filter will match columns with precision smaller than or equal to this number.
      - `sourceMaxScaleFilter` integer — Optional. The filter will match columns with scale smaller than or equal to this number.
      - `sourceMinScaleFilter` integer — Optional. The filter will match columns with scale greater than or equal to this number.
      - `numericFilterOption` 'NUMERIC_FILTER_OPTION_UNSPECIFIED' | 'NUMERIC_FILTER_OPTION_ALL' | 'NUMERIC_FILTER_OPTION_LIMIT' | 'NUMERIC_FILTER_OPTION_LIMITLESS' — Required. Enum to set the option defining the datatypes numeric filter has to be applied to
      - `sourceMinPrecisionFilter` integer — Optional. The filter will match columns with precision greater than or equal to this number.
    - `overridePrecision` integer — Optional. Column precision - when relevant - if not specified and relevant uses the source column precision.
    - `newDataType` string — Required. New data type.
    - `sourceTextFilter` SourceTextFilter — Filter for text-based data types like varchar.
      - `sourceMinLengthFilter` string, int64 — Optional. The filter will match columns with length greater than or equal to this number.
      - `sourceMaxLengthFilter` string, int64 — Optional. The filter will match columns with length smaller than or equal to this number.
    - `overrideLength` string, int64 — Optional. Column length - e.g. varchar (50) - if not specified and relevant uses the source column length.
    - `overrideScale` integer — Optional. Column scale - when relevant - if not specified and relevant uses the source column scale.
  - `conditionalColumnSetValue` ConditionalColumnSetValue — Options to configure rule type ConditionalColumnSetValue. The rule is used to transform the data which is being replicated/migrated. The rule filter field can refer to one or more entities. The rule scope can be one of: Column.
    - `sourceTextFilter` SourceTextFilter — Filter for text-based data types like varchar.
      - `sourceMinLengthFilter` string, int64 — Optional. The filter will match columns with length greater than or equal to this number.
      - `sourceMaxLengthFilter` string, int64 — Optional. The filter will match columns with length smaller than or equal to this number.
    - `valueTransformation` ValueTransformation — Description of data transformation during migration as part of the ConditionalColumnSetValue.
      - `assignNull` Empty — A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
      - `assignMinValue` Empty — A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
      - `assignMaxValue` Empty — A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
      - `doubleComparison` DoubleComparisonFilter — Filter based on relation between source value and compare value of type double in ConditionalColumnSetValue
        - `value` number, double — Required. Double compare value to be used
        - `valueComparison` 'VALUE_COMPARISON_UNSPECIFIED' | 'VALUE_COMPARISON_IF_VALUE_SMALLER_THAN' | 'VALUE_COMPARISON_IF_VALUE_SMALLER_EQUAL_THAN' | 'VALUE_COMPARISON_IF_VALUE_LARGER_THAN' | 'VALUE_COMPARISON_IF_VALUE_LARGER_EQUAL_THAN' — Required. Relation between source value and compare value
      - `roundScale` RoundToScale — This allows the data to change scale, for example if the source is 2 digits after the decimal point, specify round to scale value = 2. If for example the value needs to be converted to an integer, use round to scale value = 0.
        - `scale` integer — Required. Scale value to be used
      - `valueList` ValueListFilter — A list of values to filter by in ConditionalColumnSetValue
        - `values` string[] — Required. The list to be used to filter by
        - `ignoreCase` boolean — Required. Whether to ignore case when filtering by values. Defaults to false
        - `valuePresentList` 'VALUE_PRESENT_IN_LIST_UNSPECIFIED' | 'VALUE_PRESENT_IN_LIST_IF_VALUE_LIST' | 'VALUE_PRESENT_IN_LIST_IF_VALUE_NOT_LIST' — Required. Indicates whether the filter matches rows with values that are present in the list or those with values not present in it.
      - `assignSpecificValue` AssignSpecificValue — Set to a specific value (value is converted to fit the target data type)
        - `value` string — Required. Specific value to be assigned
      - `applyHash` ApplyHash — Apply a hash function on the value.
        - `uuidFromBytes` Empty — A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
      - `isNull` Empty — A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
      - `intComparison` IntComparisonFilter — Filter based on relation between source value and compare value of type integer in ConditionalColumnSetValue
        - `valueComparison` 'VALUE_COMPARISON_UNSPECIFIED' | 'VALUE_COMPARISON_IF_VALUE_SMALLER_THAN' | 'VALUE_COMPARISON_IF_VALUE_SMALLER_EQUAL_THAN' | 'VALUE_COMPARISON_IF_VALUE_LARGER_THAN' | 'VALUE_COMPARISON_IF_VALUE_LARGER_EQUAL_THAN' — Required. Relation between source value and compare value
        - `value` string, int64 — Required. Integer compare value to be used
    - `customFeatures` object — Optional. Custom engine specific features.
    - `sourceNumericFilter` SourceNumericFilter — Filter for fixed point number data types such as NUMERIC/NUMBER
      - `sourceMaxPrecisionFilter` integer — Optional. The filter will match columns with precision smaller than or equal to this number.
      - `sourceMaxScaleFilter` integer — Optional. The filter will match columns with scale smaller than or equal to this number.
      - `sourceMinScaleFilter` integer — Optional. The filter will match columns with scale greater than or equal to this number.
      - `numericFilterOption` 'NUMERIC_FILTER_OPTION_UNSPECIFIED' | 'NUMERIC_FILTER_OPTION_ALL' | 'NUMERIC_FILTER_OPTION_LIMIT' | 'NUMERIC_FILTER_OPTION_LIMITLESS' — Required. Enum to set the option defining the datatypes numeric filter has to be applied to
      - `sourceMinPrecisionFilter` integer — Optional. The filter will match columns with precision greater than or equal to this number.
  - `displayName` string — Optional. A human readable name
  - `revisionId` string — Output only. The revision ID of the mapping rule. A new revision is committed whenever the mapping rule is changed in any way. The format is an 8-character hexadecimal string.
  - `name` string — Full name of the mapping rule resource, in the form of: projects/{project}/locations/{location}/conversionWorkspaces/{set}/mappingRule/{rule}.
  - `filterTableColumns` FilterTableColumns — Options to configure rule type FilterTableColumns. The rule is used to filter the list of columns to include or exclude from a table. The rule filter field can refer to one entity. The rule scope can be: Table Only one of the two lists can be specified for the rule.
    - `includeColumns` string[] — Optional. List of columns to be included for a particular table.
    - `excludeColumns` string[] — Optional. List of columns to be excluded for a particular table.
  - `singleEntityRename` SingleEntityRename — Options to configure rule type SingleEntityRename. The rule is used to rename an entity. The rule filter field can refer to only one entity. The rule scope can be one of: Database, Schema, Table, Column, Constraint, Index, View, Function, Stored Procedure, Materialized View, Sequence, UDT, Synonym
    - `newName` string — Required. The new name of the destination entity
  - `filter` MappingRuleFilter — A filter defining the entities that a mapping rule should be applied to. When more than one field is specified, the rule is applied only to entities which match all the fields.
    - `entityNameSuffix` string — Optional. The rule should be applied to entities whose non-qualified name ends with the given suffix.
    - `entityNamePrefix` string — Optional. The rule should be applied to entities whose non-qualified name starts with the given prefix.
    - `entityNameContains` string — Optional. The rule should be applied to entities whose non-qualified name contains the given string.
    - `entities` string[] — Optional. The rule should be applied to specific entities defined by their fully qualified names.
    - `parentEntity` string — Optional. The rule should be applied to entities whose parent entity (fully qualified name) matches the given value. For example, if the rule applies to a table entity, the expected value should be a schema (schema). If the rule applies to a column or index entity, the expected value can be either a schema (schema) or a table (schema.table)
  - `singleColumnChange` SingleColumnChange — Options to configure rule type SingleColumnChange. The rule is used to change the properties of a column. The rule filter field can refer to one entity. The rule scope can be one of: Column. When using this rule, if a field is not specified than the destination column's configuration will be the same as the one in the source column..
    - `array` boolean — Optional. Is the column of array type.
    - `collation` string — Optional. Collation override - instead of table level collation.
    - `precision` integer — Optional. Column precision - e.g. 8 as in double (8,2) - when relevant.
    - `nullable` boolean — Optional. Is the column nullable.
    - `arrayLength` integer — Optional. The length of the array, only relevant if the column type is an array.
    - `udt` boolean — Optional. Is the column a UDT (User-defined Type).
    - `dataType` string — Optional. Column data type name.
    - `autoGenerated` boolean — Optional. Is the column auto-generated/identity.
    - `setValues` string[] — Optional. Specifies the list of values allowed in the column.
    - `length` string, int64 — Optional. Column length - e.g. 50 as in varchar (50) - when relevant.
    - `scale` integer — Optional. Column scale - e.g. 2 as in double (8,2) - when relevant.
    - `fractionalSecondsPrecision` integer — Optional. Column fractional seconds precision - e.g. 2 as in timestamp (2) - when relevant.
    - `charset` string — Optional. Charset override - instead of table level charset.
    - `customFeatures` object — Optional. Custom engine specific features.
    - `comment` string — Optional. Comment associated with the column.

## Response `200`

Successful response

---

[API](https://skmtc.dev/google/apis/datamigration.md) · [All operations](https://skmtc.dev/google/apis/datamigration/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/google/datamigration/revisions/d77bd66e25e6/schema)
