# Migrating models

Migrating a Compose Model allows you to:

* Import existing column definitions (i.e. definitions stored independently of Compose) to a Compose project
* Reuse the same Model across several projects or Compose installations

## Model objects

[](https://help.qlik.com/en-US/compose/Content/ComposeDWDL/Main/DW/Projects/export_import_model.htm)A Compose Model consists of the following objects:

* Entities (entities.csv)
* Attributes (attributes.csv)
* Attributes Domain (attributesDomain.csv)
* Relationships (relationships.csv)

During the export process, each of these objects is exported to a separate CSV file.

You can either import the Model in its entirety or only specific elements, according to your needs. You can also manually create a CSV file containing a Model element (or edit an existing file) and then import it to a Compose project.

Information note

* The Model must be valid before you can export it to or import it from a CSV file. For details, see [Validating the model](https://help.qlik.com/en-US/compose/December2024/Content/ComposeDWDL/Main/DW/Model/validate_model.htm).

* CSV files must be in a valid format. For details, see [Valid CSV File Formats](https://help.qlik.com/en-US/compose/December2024/Content/ComposeDWDL/Main/DW/Projects/export_import_model.htm#Valid).

* Only a user with Model privileges can import the Model.

  Non-privileged users can import just the mappings. For details, see the SCOPE parameter in the [command for importing a model](https://help.qlik.com/en-US/compose/December2024/Content/ComposeDWDL/Main/DW/Projects/CLI_for_ExportImport_Objects.htm).

* Replacing an existing object is not supported. For example, if the Products entity already exists in the Model, you cannot import an entities.csv file that contains an entity called Products.

## Guidelines for exporting a Compose model

Note the following:

* For Boolean fields, accepted values are True/False
* Data type is the Compose logical type
* The order of writing the attributes is according to the ordinal in the entity. Primary Keys will be shown first, even if they were not first in the source model
* Attribute domain and entity order is alphabetical in the CSV
* Relationship order is by entity name (alphabetical) and according to their order in the entity

## Guidelines for importing a Compose model

Note the following:

* For boolean fields, accepted values are True/False

* Column order has no meaning; only column names, which are case insensitive, unless defined differently

* If the entities.csv file is missing, the entities can be inferred from the attributes.csv file (with no description). In such cases, duplicate objects are verified to be the same and added only once. For example, if there are several rows with entity name myEntity, the entity will only be added once

* Data type is the Compose logical type

* Relationship details override the underlying attributes information (e.g. history type, is key, etc.)

* When importing the attributes.csv file, a new entity will not be created if wasn’t already created in the entities.csv file, and its attributes all have relationships to other entities. In such cases, you should create the entity manually or add it to the entities.csv file

* When importing the relationships.csv file, existing attributes will be replaced if:

  `child attribute prefix+attribute name = relationship_prefix+parent_attribute_name_prefix+parent_attribute_name`

  For example, the attribute named `CustomerDesignatedID` will be replaced by the relationship where:

* `ID` is the name of the attribute in the parent entity and

* ` Customer  `is the prefix of the relationship and

* ` Designated  `is the prefix of the parent attribute.

  Note that attributes marked as relationships will be skipped when imported from attributes.csv as they must derive their data type from the Attributes Domain.

### Entities CSV file format

Entity CSV mapping rules

| Column Name | Required | If column/value is missing | Comments |
| --- | --- | --- | --- |
| Entity Name | Yes | Reject | Case insensitive |
| Entity Description | No | Empty | - |

### Attributes CSV file format

Information note

If `Attribute Domain` is missing in the attributes.csv file, there must be a data type. Attribute domains that differ but have the same name will be appended with the suffix \_01.

Attribute CSV mapping rules

| Column Name | Required | If column is missing | If value is missing | Comments |
| --- | --- | --- | --- | --- |
| Entity Name | Yes | Reject | Reject | Case insensitive |
| Attribute Name | Yes | Reject | Reject | Case insensitive |
| Description | No | Empty | Accept | - |
| Is Key | No | No attributes will be defined as keys. In such a case, validation will fail as at least one key needs to be defined. | No Key | On import, Compose *does not* validate that each entity has at least one key attribute (required).<br>If you import entities without key attributes, then you must define a key attribute in Compose after importing the entity. Otherwise, Model validation will fail. |
| Attribute Domain | No | If it is missing, Data Type must exist and attribute domains will be built or used the same as they are during discovery. | Reject | The Attribute Domain name or the word "Relationship" |
| Data Type | No | If it is missing, the Attribute Domain must exist. An error will be returned if the data type does not match the attribute domain or if both exist. | Reject | Use combined syntax:<br><br>Varchar(50)<br><br>Decimal(10,2) |
| Prefix | No | Empty | Accept (an empty feld means there will be no prefix) | - |
| History Type | No | Key - Type 1, Not key - type 2 | Reject | Values are Type 1 or Type 2.<br><br>Yes (Type 2) and No (Type 1) are also allowed. |
| Satellite/Hub | No | Key is Hub; other attributes are SAT 1 | Reject | Hub/1/2/3 |
| Expression | No | No expressions in any attribute | No expression in any attribute | - |
| Expresssion Params | No | All attribute-parameter mappings are trivial (same name) | All attribute-parameter mappings are trivial (same name) | - |
| Add after | No | Not relevant. | Not relevant. | Instructs Compose to add the attribute after a specific attribute. The column is only relevant when adding attributes. When the column is empty, the corresponding attributes should be added at the end (according to their order in the CSV file).<br><br>Note that it may refer to any attribute that is defined above the current row.<br><br>For example, assuming a record contains the attributes address, height, and weight,<br>specifying the following:<br><br>school, add after=weight<br><br>ID, add after=school<br><br>email, add after=empty<br><br>Will result in the following order: address, height, weight, school, ID, email |

### Attributes Domain CSV file format

Attributes Domain CSV mapping rules

| Column Name | Required | If column is missing | If value is missing | Comments |
| --- | --- | --- | --- | --- |
| Name | Yes | Reject | Reject | Case insensitive |
| Description | No | Empty | The specific attribute value may be empty as well. | - |
| Data Type | No | Reject | Reject | Use combined syntax:<br><br>Varchar(50)<br><br>Decimal(10,2) |

### Relationships

Relationships CSV mapping rules

| Column Name | Required | If column is missing | If value is missing | Comments |
| --- | --- | --- | --- | --- |
| Child Entity | Yes | Reject | Reject | This is the more detailed entity (e.g. OrderDetails).<br>Case insensitive. |
| Parent Entity | Yes | Reject | Reject | This is the less detailed entity (e.g. Products).<br>Case insensitive. |
| Prefix | No | Empty<br><br>If there are several relationships from the same source to the same target, a prefix must be added. | If all the originating attributes have the same prefix, use it here.<br><br>A relationship may not have a prefix to its underlying attributes.<br><br>The specific attribute value may be empty as well. | - |
| Position After | No | Add the relationships to the end. Relationships are ordered according to their order in the file. | Same as missing column | The attribute name or relationship to position it after or ”0” to position it first. |
| Description | No | Empty | Specific attribute may have empty value as well | - |
| Is Key | No | No attributes will be defined as keys. In such a case, validation will fail as at least one key needs to be defined. | No key | - |
| History Type | No | Key: Type 1<br><br>Non-key: Type 2 | Reject | Values are Type 1 or Type 2.<br><br>Yes (Type 2) and No (Type 1) are also allowed. |
| Satellite/Hub | No | Key: Hub<br><br>Other attributes: SAT 1 | Reject | Hub/1/2/3 |