[[store_migrator]]
=== Store Migrator
ifndef::productized[]
{brandname} 9.0 introduced changes to internal marshalling functionality that are not backwardly compatible with previous versions of {brandname}. As a result, {brandname} 9.x and later cannot read cache stores created in earlier versions of {brandname}.
endif::productized[]
ifdef::productized[]
{brandname} 7.3 introduced changes to internal marshalling functionality that are not backwardly compatible with previous versions of {brandname}. As a result, {brandname} 7.3.x and later cannot read cache stores created in earlier versions of {brandname}.
endif::productized[]
Additionally, {brandname} no longer provides some store implementations such as JDBC Mixed and Binary stores.

You can use `StoreMigrator.java` to migrate cache stores. This migration tool reads data from cache stores in previous versions and rewrites the content for compatibility with the current marshalling implementation.

==== Migrating Cache Stores
To perform a migration with `StoreMigrator`,

. Put `infinispan-tools-{infinispanversion}.jar` and dependencies for your source and target databases, such as JDBC drivers, on your classpath.
. Create a `.properties` file that contains configuration properties for the source and target cache stores.
+
You can find an example properties file that contains all applicable configuration options in link:https://github.com/infinispan/infinispan/blob/master/tools/src/main/resources/migrator.properties[migrator.properties].
+
. Specify `.properties` file as an argument for `StoreMigrator`.
. Run `mvn exec:java` to execute the migrator.

See the following example Maven `pom.xml` for `StoreMigrator`:

include::topics/dependencies/persistence_storemigrator.adoc[]

==== Store Migrator Properties
All migrator properties are configured within the context of a source or target store. Each property must start with either `source.` or `target.`.

All properties in the following sections apply to both source and target stores,
except for `table.binary.*` properties because it is not possible to migrate to a binary table.

===== Common Properties

[options="header"]
|===
|Property|Description|Example value|Required
|type | JDBC_STRING \| JDBC_BINARY \| JDBC_MIXED \| LEVELDB \| ROCKSDB \| SINGLE_FILE_STORE \| SOFT_INDEX_FILE_STORE | JDBC_MIXED | TRUE
|cache_name | The name of the cache associated with the store | persistentMixedCache | TRUE
//Exclude segmentation support from productized docs.
ifndef::productized[]
|segment_count | How many segments this store will be created with. If not provided store will not be segmented. (supported as target only - JDBC not yet supported) | null |  FALSE
endif::productized[]
|===

ifndef::productized[]
It should be noted that the *segment_count* property should match how many
segments your cache will be using. That is that it should match the
`clustering.hash.numSegments` config value. If these do not match, data
will not be properly read when running the cache.
endif::productized[]

===== JDBC Properties
[options="header"]
|===============
|Property|Description|Example value|Required
|dialect | The dialect of the underlying database | POSTGRES | TRUE
|marshaller.type | The marshaller to use for the store. Possible values are:

ifndef::productized[]
- `LEGACY` {brandname} 8.2.x marshaller. Valid for source stores only.
endif::productized[]
ifdef::productized[]
- `LEGACY` {brandname} 7.2.x marshaller. Valid for source stores only.
endif::productized[]

ifndef::productized[]
- `CURRENT` {brandname} 9.x marshaller.
endif::productized[]
ifdef::productized[]
- `CURRENT` {brandname} 7.3.x marshaller.
endif::productized[]

- `CUSTOM` Custom marshaller.

| CURRENT | TRUE
|marshaller.class | The class of the marshaller if type=CUSTOM | org.example.CustomMarshaller |
|marshaller.externalizers | A comma-separated list of custom AdvancedExternalizer implementations to load `[id]:<Externalizer class>` | `25:Externalizer1,org.example.Externalizer2` |
|connection_pool.connection_url | The JDBC connection url | `jdbc:postgresql:postgres` | TRUE
|connection_pool.driver_class | The class of the JDBC driver | org.postrgesql.Driver | TRUE
|connection_pool.username | Database username | | TRUE
|connection_pool.password | Database password | | TRUE
|db.major_version | Database major version | 9 |
|db.minor_version | Database minor version | 5 |
|db.disable_upsert | Disable db upsert | false |
|db.disable_indexing | Prevent table index being created | false |
|table.`<binary\|string>`.table_name_prefix | Additional prefix for table name | tablePrefix |
|table.`<binary\|string>`.`<id\|data\|timestamp>`.name | Name of the column | id_column | TRUE
|table.`<binary\|string>`.`<id\|data\|timestamp>`.type | Type of the column | VARCHAR | TRUE
|key_to_string_mapper | TwoWayKey2StringMapper Class | `org.infinispan.persistence.keymappers. DefaultTwoWayKey2StringMapper` |
|===============

===== LevelDB/RocksDB Properties
[options="header"]
|===============
|Property|Description|Example value|Required
|location | The location of the db directory | /some/example/dir | TRUE
|compression | The compression type to be used | SNAPPY |
|===============

===== SingleFileStore Properties
[options="header"]
|===============
|Property|Description|Example value|Required
|location | The directory containing the store's .dat file | /some/example/dir | TRUE
|===============

===== SoftIndexFileStore Properties
[options="header"]
|===============
|Property|Description|Example value|Required
|location | The location of the db directory | /some/example/dir | TRUE
|index_location | The location of the db's index | /some/example/dir-index | Target Only
|===============
