Transformation rules in DMS Schema Conversion
Transformation rules let you customize how DMS Schema Conversion converts your database objects, overriding default naming and data type mappings. You can apply these rules to databases, schemas, tables, views, columns, function return values, routine parameters, and local variables.
For example, suppose that you have a set of tables in your source schema named
test_TABLE_NAME. You can set up a rule that changes the prefix
test_ to the prefix demo_ in the target
schema.
You can create transformation rules that perform the following tasks:
-
Add, remove, or replace a prefix
-
Add, remove, or replace a suffix
-
Change the data type of a column, function return value, routine parameter, or local variable
-
Convert the object name to lowercase or uppercase
-
Rename an object
Creating transformation rules
DMS Schema Conversion stores transformation rules as part of your migration project. To
define transformation rules, pass them as a JSON string that contains an object
with a rules array when you create or modify a migration project.
Each element in the array represents a separate rule object. A migration
project supports up to 512 transformation rules (128 KB maximum).
The structure of the array with transformation rules is as follows:
{ "rules": [ {Rule object 1}, {Rule object 2}, ... {Rule object N} ] }
You can add multiple transformation rules in your project. DMS Schema Conversion applies transformation rules during conversion in the same order as you added them.
If multiple rules target the same object, the behavior depends on the
action type. Rules with different action types all take effect. For example,
an add-prefix rule and an add-suffix rule both
apply. Rules with the same action type override each other, and only the last one
takes effect.
To create transformation rules, use one of the following methods.
To edit, duplicate, or remove existing transformation rules, see Editing transformation rules.
Retrieving transformation rules
You can retrieve transformation rules from an existing DMS Schema Conversion migration project using the AWS Management Console or the AWS CLI.
Editing transformation rules
To edit, add, or remove transformation rules in your migration project, use one of the following methods.
Transformation rule format
A transformation rule uses JSON object fields to define how to convert a source object into its target equivalent. Each rule type uses a specific set of fields. Include only the fields that apply to your task.
The following JSON object describes a DMS Schema Conversion transformation rule:
{ "rule-type": "transformation", "rule-id":rule_id, "rule-name": "rule_name", "rule-action": "rule_action", "rule-target": "rule_target", "object-locator": { [ "database-name": "database_name", ] [ "schema-name": "schema_name", ] [ "table-name": "table_name", ] [ "column-name": "column_name", ] [ "parent": "parent_name", ] [ "function-name": "function_name", ] [ "procedure-name": "procedure_name", ] [ "parameter-name": "parameter_name", ] [ "local-variable-name": "local_variable_name", ] [ "type": "source_data_type", ] [ "precision":source_precision, ] [ "scale":source_scale, ] [ "length":source_length] }, [ "value": "rule_value", ] [ "old-value": "rule_old_value", ] [ "data-type": { "type": "data_type_name", [ "precision":data_type_precision, ] [ "scale":data_type_scale, ] [ "length":data_type_length] } ] }
The following table describes each parameter.
| Parameter | Possible values | Description |
|---|---|---|
rule-type |
transformation |
A value that applies the rule to each object specified by the object locator. For all transformation rules, set this to
Required parameter. |
rule-id |
A numeric (integer) value. | A unique numeric value to identify the rule. Required parameter. |
rule-name |
An alphanumeric value. | A unique name to identify the rule. Required parameter. |
rule-action |
add-prefix, remove-prefix,
replace-prefix, add-suffix,
remove-suffix, replace-suffix,
convert-uppercase,
convert-lowercase, rename,
change-data-type |
The transformation you want to apply to the object. All transformation rule actions are case-sensitive. Prefix operations:
Suffix operations:
Case conversion:
Direct modification:
Scope: prefix, suffix, rename, and case conversion operations can be applied to schemas, tables, and columns. The Required parameter. |
rule-target |
database, schema,
table, view,
column, function result,
routine parameter, local
variable |
The type of object to which the rule will be applied.
Required parameter. |
object-locator |
A JSON object. | An object that identifies which source
database objects the rule applies to. You can use
the percent sign ( The object contains the following string fields:
All object names, such as table or column names, in transformation rules are case-sensitive. The following sections describe each object field. Required parameter. |
object-locator | database-name |
An alphanumeric value that follows the naming rules for the source database. | The name of the source database. Applicable for database vendors where the database architecture originates from the database as the top-level container of objects. For example: Microsoft SQL Server, SAP ASE. Optional JSON object field. |
object-locator | schema-name |
An alphanumeric value that follows the naming rules for the source database. | The name of the source database schema. Optional JSON object field. |
object-locator | table-name |
An alphanumeric value that follows the naming rules for the source database. | The name of the source database table. Optional JSON object field. |
object-locator | column-name |
An alphanumeric value that follows the naming rules for the source database. | The name of the source database table column. Optional JSON object field. |
object-locator | parent |
An alphanumeric value that follows the naming rules for the source database. | The name of the source database object that is the
parent of the specified object, for example, for the
In databases of some vendors, the object to which the rule is applied may be subordinate and require specifying its parent. For example, packaged functions in Oracle, where the parent is the package name. Optional JSON object field. |
object-locator | function-name |
An alphanumeric value that follows the naming rules for the source database. | The name of the source database function. Optional JSON object field. |
object-locator | procedure-name |
An alphanumeric value that follows the naming rules for the source database. | The name of the source database procedure. Optional JSON object field. |
object-locator | parameter-name |
An alphanumeric value that follows the naming rules for the source database. | The name of the source database function or procedure parameter. Optional JSON object field. |
object-locator | local-variable-name |
An alphanumeric value that follows the naming rules for the source database. | The name of a local variable within the source database function or procedure. Optional JSON object field. |
object-locator | type |
An alphanumeric value. | The source data type name to match. Use this field to apply the rule only to objects with a specific data type. Optional JSON object field. |
object-locator | precision |
A numeric (integer) value. | The precision of the source data type to match. Optional JSON object field. |
object-locator | scale |
A numeric (integer) value. | The scale of the source data type to match. Optional JSON object field. |
object-locator | length |
A numeric (integer) value. | The length of the source data type to match. Optional JSON object field. |
value |
An alphanumeric value that follows the naming rules for the target database. | The text value used by the transformation
action. For Required for all actions except
|
old-value |
An alphanumeric value that follows the naming rules for the source database. | The existing value to find and replace in the
object name. Required for actions such as
Optional parameter. |
data-type |
A JSON object. | An object describing replacement data type properties
when The object contains the following fields:
The following sections describe each object field. Optional parameter. |
data-type | type |
An alphanumeric value. | The name of the replacement data type for the target
database column if the Required JSON object field. |
data-type | precision |
A numeric (integer) value. | The precision of the replacement data type for the
target database if the Optional JSON object field. |
data-type | scale |
A numeric (integer) value. | The scale of the replacement data type for the target
database if the Optional JSON object field. |
data-type | length |
A numeric (integer) value. | The length of the replacement data type for the target
database if the Optional JSON object field. |
Transformation rule examples
The following examples show the JSON value for the
--transformation-rules parameter for different rule types:
The following example performs these actions when converting from source to target database:
-
Add prefix
DW_to schemaSALES. -
Add prefix
FACT_to tableORDERSin schemaSALES. -
Add prefix
OLD_to columnUNIT_PRICEin tablePRODUCTSin schemaSALES.
{ "rules": [ { "rule-id": 5, "rule-type": "transformation", "rule-name": "add-prefix-schema-sales", "rule-action": "add-prefix", "rule-target": "schema", "object-locator": { "schema-name": "SALES" }, "value": "DW_" }, { "rule-id": 12, "rule-type": "transformation", "rule-name": "add-prefix-table-orders", "rule-action": "add-prefix", "rule-target": "table", "object-locator": { "schema-name": "SALES", "table-name": "ORDERS" }, "value": "FACT_" }, { "rule-id": 27, "rule-type": "transformation", "rule-name": "add-prefix-column-unit-price", "rule-action": "add-prefix", "rule-target": "column", "object-locator": { "schema-name": "SALES", "table-name": "PRODUCTS", "column-name": "UNIT_PRICE" }, "value": "OLD_" } ] }
The following example performs these actions when converting from source to target database:
-
Remove prefix
SRC_from schemaSRC_FINANCE. -
Remove prefix
TMP_from tableTMP_INVOICESin schemaSRC_FINANCE. -
Remove prefix
PAID_from columnPAID_AMOUNTin tableTMP_PAYMENTSin schemaSRC_FINANCE.
{ "rules": [ { "rule-id": 3, "rule-type": "transformation", "rule-name": "remove-prefix-schema-src-finance", "rule-action": "remove-prefix", "rule-target": "schema", "object-locator": { "schema-name": "SRC_FINANCE" }, "value": "SRC_" }, { "rule-id": 18, "rule-type": "transformation", "rule-name": "remove-prefix-table-tmp-invoices", "rule-action": "remove-prefix", "rule-target": "table", "object-locator": { "schema-name": "SRC_FINANCE", "table-name": "TMP_INVOICES" }, "value": "TMP_" }, { "rule-id": 41, "rule-type": "transformation", "rule-name": "remove-prefix-column-paid-amount", "rule-action": "remove-prefix", "rule-target": "column", "object-locator": { "schema-name": "SRC_FINANCE", "table-name": "TMP_PAYMENTS", "column-name": "PAID_AMOUNT" }, "value": "PAID_" } ] }
The following example performs these actions when converting from source to target database:
-
Replace prefix
OLD_withNEW_in schemaOLD_INVENTORY. -
Replace prefix
STG_withINT_in tableSTG_WAREHOUSESin schemaOLD_INVENTORY. -
Replace prefix
SRC_withTGT_in columnSRC_WAREHOUSE_CODEin tableSTG_WAREHOUSESin schemaOLD_INVENTORY.
{ "rules": [ { "rule-id": 7, "rule-type": "transformation", "rule-name": "replace-prefix-schema-old-inventory", "rule-action": "replace-prefix", "rule-target": "schema", "object-locator": { "schema-name": "OLD_INVENTORY" }, "value": "NEW_", "old-value": "OLD_" }, { "rule-id": 22, "rule-type": "transformation", "rule-name": "replace-prefix-table-stg-warehouses", "rule-action": "replace-prefix", "rule-target": "table", "object-locator": { "schema-name": "OLD_INVENTORY", "table-name": "STG_WAREHOUSES" }, "value": "INT_", "old-value": "STG_" }, { "rule-id": 35, "rule-type": "transformation", "rule-name": "replace-prefix-column-src-warehouse-code", "rule-action": "replace-prefix", "rule-target": "column", "object-locator": { "schema-name": "OLD_INVENTORY", "table-name": "STG_WAREHOUSES", "column-name": "SRC_WAREHOUSE_CODE" }, "value": "TGT_", "old-value": "SRC_" } ] }
The following example performs these actions when converting from source to target database:
-
Add suffix
_HISTto schemaHR_ARCHIVE. -
Add suffix
_HISTto tableJOB_CHANGESin schemaHR_ARCHIVE. -
Add suffix
_TSto columnCREATED_ATin tableEMPLOYEE_SALARIESin schemaHR_ARCHIVE.
{ "rules": [ { "rule-id": 9, "rule-type": "transformation", "rule-name": "add-suffix-schema-hr-archive", "rule-action": "add-suffix", "rule-target": "schema", "object-locator": { "schema-name": "HR_ARCHIVE" }, "value": "_HIST" }, { "rule-id": 16, "rule-type": "transformation", "rule-name": "add-suffix-table-job-changes", "rule-action": "add-suffix", "rule-target": "table", "object-locator": { "schema-name": "HR_ARCHIVE", "table-name": "JOB_CHANGES" }, "value": "_HIST" }, { "rule-id": 44, "rule-type": "transformation", "rule-name": "add-suffix-column-created-at", "rule-action": "add-suffix", "rule-target": "column", "object-locator": { "schema-name": "HR_ARCHIVE", "table-name": "EMPLOYEE_SALARIES", "column-name": "CREATED_AT" }, "value": "_TS" } ] }
The following example performs these actions when converting from source to target database:
-
Remove suffix
_FILESfrom schemaLEGAL_FILES. -
Remove suffix
_V1from tableCLAUSES_V1in schemaLEGAL_FILES. -
Remove suffix
_CODEfrom columnCOUNTRY_CODEin tableCONTRACTS_V1in schemaLEGAL_FILES.
{ "rules": [ { "rule-id": 6, "rule-type": "transformation", "rule-name": "remove-suffix-schema-legal-files", "rule-action": "remove-suffix", "rule-target": "schema", "object-locator": { "schema-name": "LEGAL_FILES" }, "value": "_FILES" }, { "rule-id": 14, "rule-type": "transformation", "rule-name": "remove-suffix-table-clauses-v1", "rule-action": "remove-suffix", "rule-target": "table", "object-locator": { "schema-name": "LEGAL_FILES", "table-name": "CLAUSES_V1" }, "value": "_V1" }, { "rule-id": 31, "rule-type": "transformation", "rule-name": "remove-suffix-column-country-code", "rule-action": "remove-suffix", "rule-target": "column", "object-locator": { "schema-name": "LEGAL_FILES", "table-name": "CONTRACTS_V1", "column-name": "COUNTRY_CODE" }, "value": "_CODE" } ] }
The following example performs these actions when converting from source to target database:
-
Replace suffix
_DEVwith_PRODin schemaREPORTING_DEV. -
Replace suffix
_RPTwith_REPORTin tableMONTHLY_RPTin schemaREPORTING_DEV. -
Replace suffix
_IDwith_KEYin columnCUSTOMER_IDin tableMONTHLY_RPTin schemaREPORTING_DEV.
{ "rules": [ { "rule-id": 8, "rule-type": "transformation", "rule-name": "replace-suffix-schema-reporting-dev", "rule-action": "replace-suffix", "rule-target": "schema", "object-locator": { "schema-name": "REPORTING_DEV" }, "value": "_PROD", "old-value": "_DEV" }, { "rule-id": 23, "rule-type": "transformation", "rule-name": "replace-suffix-table-monthly-rpt", "rule-action": "replace-suffix", "rule-target": "table", "object-locator": { "schema-name": "REPORTING_DEV", "table-name": "MONTHLY_RPT" }, "value": "_REPORT", "old-value": "_RPT" }, { "rule-id": 47, "rule-type": "transformation", "rule-name": "replace-suffix-column-customer-id", "rule-action": "replace-suffix", "rule-target": "column", "object-locator": { "schema-name": "REPORTING_DEV", "table-name": "MONTHLY_RPT", "column-name": "CUSTOMER_ID" }, "value": "_KEY", "old-value": "_ID" } ] }
The following example performs these actions when converting from source to target database:
-
Convert all characters in the name of schema
CRM_LEGACYto uppercase. -
Convert all characters in the name of table
CUSTOMER_ACCOUNTSin schemaCRM_LEGACYto uppercase. -
Convert all characters in the name of column
FIRST_NAMEin tableCUSTOMER_ACCOUNTSin schemaCRM_LEGACYto uppercase.
{ "rules": [ { "rule-id": 4, "rule-type": "transformation", "rule-name": "convert-uppercase-schema-crm-legacy", "rule-action": "convert-uppercase", "rule-target": "schema", "object-locator": { "schema-name": "CRM_LEGACY" } }, { "rule-id": 19, "rule-type": "transformation", "rule-name": "convert-uppercase-table-customer-accounts", "rule-action": "convert-uppercase", "rule-target": "table", "object-locator": { "schema-name": "CRM_LEGACY", "table-name": "CUSTOMER_ACCOUNTS" } }, { "rule-id": 36, "rule-type": "transformation", "rule-name": "convert-uppercase-column-first-name", "rule-action": "convert-uppercase", "rule-target": "column", "object-locator": { "schema-name": "CRM_LEGACY", "table-name": "CUSTOMER_ACCOUNTS", "column-name": "FIRST_NAME" } } ] }
The following example performs these actions when converting from source to target database:
-
Convert all characters in the name of schema
LOGISTICSto lowercase. -
Convert all characters in the name of table
SHIPMENT_ORDERSin schemaLOGISTICSto lowercase. -
Convert all characters in the name of column
DESTINATION_CITYin tableSHIPMENT_ORDERSin schemaLOGISTICSto lowercase.
{ "rules": [ { "rule-id": 11, "rule-type": "transformation", "rule-name": "convert-lowercase-schema-logistics", "rule-action": "convert-lowercase", "rule-target": "schema", "object-locator": { "schema-name": "LOGISTICS" } }, { "rule-id": 25, "rule-type": "transformation", "rule-name": "convert-lowercase-table-shipment-orders", "rule-action": "convert-lowercase", "rule-target": "table", "object-locator": { "schema-name": "LOGISTICS", "table-name": "SHIPMENT_ORDERS" } }, { "rule-id": 52, "rule-type": "transformation", "rule-name": "convert-lowercase-column-destination-city", "rule-action": "convert-lowercase", "rule-target": "column", "object-locator": { "schema-name": "LOGISTICS", "table-name": "SHIPMENT_ORDERS", "column-name": "DESTINATION_CITY" } } ] }
The following example performs these actions when converting from source to target database:
-
Rename schema
TEST_SCHEMAtoTEST_NEW_SCHEMA. -
Rename table
REGIONSin schemaHRtoORG_REGIONS. -
Rename column
CITYin tableLOCATIONSin schemaHRtoORG_CITY_NAME.
{ "rules": [ { "rule-id": 2, "rule-type": "transformation", "rule-name": "rename-schema-test-schema", "rule-action": "rename", "rule-target": "schema", "object-locator": { "schema-name": "TEST_SCHEMA" }, "value": "TEST_NEW_SCHEMA" }, { "rule-id": 15, "rule-type": "transformation", "rule-name": "rename-table-hr-regions", "rule-action": "rename", "rule-target": "table", "object-locator": { "schema-name": "HR", "table-name": "REGIONS" }, "value": "ORG_REGIONS" }, { "rule-id": 38, "rule-type": "transformation", "rule-name": "rename-column-hr-locations-city", "rule-action": "rename", "rule-target": "column", "object-locator": { "schema-name": "HR", "table-name": "LOCATIONS", "column-name": "CITY" }, "value": "ORG_CITY_NAME" } ] }
The following example performs these actions when converting from source to target database:
-
Change the data type of column
SALARYin tableEMPLOYEESin schemaPAYROLLfromNUMBERtoDECIMALwith precision 18 and scale 4. -
Change the data type of column
NOTESin tableEMPLOYEESin schemaPAYROLLfromVARCHAR2toVARCHARwith length 350. -
Change the data type of column
HIRE_DATEin tableEMPLOYEESin schemaPAYROLLfromDATEtoTIMESTAMP WITH TIME ZONEwith precision 3.
{ "rules": [ { "rule-id": 10, "rule-type": "transformation", "rule-name": "change-datatype-column-salary", "rule-action": "change-data-type", "rule-target": "column", "object-locator": { "schema-name": "PAYROLL", "table-name": "EMPLOYEES", "column-name": "SALARY" }, "data-type": { "type": "DECIMAL", "precision": 18, "scale": 4 } }, { "rule-id": 29, "rule-type": "transformation", "rule-name": "change-datatype-column-notes", "rule-action": "change-data-type", "rule-target": "column", "object-locator": { "schema-name": "PAYROLL", "table-name": "EMPLOYEES", "column-name": "NOTES" }, "data-type": { "type": "VARCHAR", "length": 350 } }, { "rule-id": 56, "rule-type": "transformation", "rule-name": "change-datatype-column-hire-date", "rule-action": "change-data-type", "rule-target": "column", "object-locator": { "schema-name": "PAYROLL", "table-name": "EMPLOYEES", "column-name": "HIRE_DATE" }, "data-type": { "type": "TIMESTAMP WITH TIME ZONE", "precision": 3 } } ] }
The following example performs these actions when converting from source to target database:
-
Change the data type of parameter
P_AMOUNTin stored procedurePROCESS_PAYMENTin schemaFINANCEtoNUMERIC. -
Change the data type of local variable
V_TAX_RATEin stored procedurePROCESS_PAYMENTin schemaFINANCEtoNUMERICwith precision 10 and scale 6. -
Change the data type of local variable
V_DESCRIPTIONin standalone functionCALC_DISCOUNTin schemaFINANCEtoCHARACTERwith length 150.
{ "rules": [ { "rule-id": 7, "rule-type": "transformation", "rule-name": "change-datatype-param-p-amount", "rule-action": "change-data-type", "rule-target": "routine parameter", "object-locator": { "schema-name": "FINANCE", "procedure-name": "PROCESS_PAYMENT", "parameter-name": "P_AMOUNT" }, "data-type": { "type": "NUMERIC" } }, { "rule-id": 21, "rule-type": "transformation", "rule-name": "change-datatype-localvar-v-tax-rate", "rule-action": "change-data-type", "rule-target": "local variable", "object-locator": { "schema-name": "FINANCE", "procedure-name": "PROCESS_PAYMENT", "local-variable-name": "V_TAX_RATE" }, "data-type": { "type": "NUMERIC", "precision": 10, "scale": 6 } }, { "rule-id": 43, "rule-type": "transformation", "rule-name": "change-datatype-localvar-v-description", "rule-action": "change-data-type", "rule-target": "local variable", "object-locator": { "schema-name": "FINANCE", "function-name": "CALC_DISCOUNT", "local-variable-name": "V_DESCRIPTION" }, "data-type": { "type": "CHARACTER", "length": 150 } } ] }
The following example performs these actions when converting from source to target database:
-
Change the return data type of standalone function
GET_PRODUCT_PRICEin schemaFNG_COMPANYtoBIGINT. -
Change the return data type of standalone function
CALC_DISCOUNTED_PRICEin schemaFNG_COMPANYtoDECIMAL. -
Change the return data type of packaged function
CALCULATE_TAXwithin packageTAX_UTILSin schemaFNG_COMPANYtoREAL.
{ "rules": [ { "rule-id": 13, "rule-type": "transformation", "rule-name": "change-result-type-get-product-price", "rule-action": "change-data-type", "rule-target": "function result", "object-locator": { "schema-name": "FNG_COMPANY", "function-name": "GET_PRODUCT_PRICE" }, "data-type": { "type": "BIGINT" } }, { "rule-id": 28, "rule-type": "transformation", "rule-name": "change-result-calc-discounted-price", "rule-action": "change-data-type", "rule-target": "function result", "object-locator": { "schema-name": "FNG_COMPANY", "function-name": "CALC_DISCOUNTED_PRICE" }, "data-type": { "type": "DECIMAL" } }, { "rule-id": 61, "rule-type": "transformation", "rule-name": "change-result-type-calculate-tax", "rule-action": "change-data-type", "rule-target": "function result", "object-locator": { "schema-name": "FNG_COMPANY", "parent": "TAX_UTILS", "function-name": "CALCULATE_TAX" }, "data-type": { "type": "REAL" } } ] }
The following example performs these actions when converting from source to target database:
-
Add prefix
MIGR_to all schemas whose names start withSTG_. -
Add prefix
MIGR_to all tables in all schemas whose names start withSTG_. -
Add suffix
_NEWto all columns whose names start withSRC_in all tables across all schemas whose names start withSTG_.
{ "rules": [ { "rule-id": 8, "rule-type": "transformation", "rule-name": "add-prefix-schemas-starting-with-stg", "rule-action": "add-prefix", "rule-target": "schema", "object-locator": { "schema-name": "STG_%" }, "value": "MIGR_" }, { "rule-id": 33, "rule-type": "transformation", "rule-name": "add-prefix-all-tables-in-stg-schemas", "rule-action": "add-prefix", "rule-target": "table", "object-locator": { "schema-name": "STG_%", "table-name": "%" }, "value": "MIGR_" }, { "rule-id": 57, "rule-type": "transformation", "rule-name": "add-suffix-columns-starting-with-src", "rule-action": "add-suffix", "rule-target": "column", "object-locator": { "schema-name": "STG_%", "table-name": "%", "column-name": "SRC_%" }, "value": "_NEW" } ] }