# Profile data migration

To make it easier to collect data to a Profile, Batch has added two automatic ways to migrate old installation's data on a Profile:

* User will be automatically identified (logged-in) if he had a Batch `custom_user_id` set on the local storage.
* User natives (language/region) and custom data will be automatically migrated to a Profile.

These migrations are triggered when your application on the dashboard is attached to a Project. Concretely this mean that there's two possible scenarios:

* Your app is running on the plugin v1 and is already attached to a Project : migrations will be triggered on the first start running on plugin v2.
* Your app is running on the plugin v2 but not attached to a Project: migrations will be triggered on the first start after your app is attached to a project.

These migrations are enabled by default, but you may want to disable them, to do so add the following :

**Android**

You can programmatically update the plugin configuration from your `Application` subclass in the native `android` directory by using:

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
// Whether Batch should automatically identify user when running the plugin v2 for the first time.
// This mean user with a custom_user_id will be automatically attached a to a Profile and could be targeted within a Project scope.
BatchFlutterPlugin.getConfiguration(this).isProfileCustomIdMigrationEnabled = false

// Whether Batch should automatically attach current installation's data (language/region/customDataAttributes...)
// to the User's Profile when running the plugin v2 for the first time.
BatchFlutterPlugin.getConfiguration(this).isProfileCustomDataMigrationEnabled = false
```

{% endtab %}

{% tab title="Java" %}

```java
// Whether Batch should automatically identify user when running the plugin v2 for the first time.
// This mean user with a custom_user_id will be automatically attached a to a Profile and could be targeted within a Project scope.
BatchFlutterPlugin.getConfiguration(this).setProfileCustomIdMigrationEnabled(false);

// Whether Batch should automatically attach current installation's data (language/region/customDataAttributes...)
// to the User's Profile when running the plugin v2 for the first time.
BatchFlutterPlugin.getConfiguration(this).setProfileCustomDataMigrationEnabled(false);
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Remember to make modifications before calling the `setup` method since all configuration changes made after will not be applied.
{% endhint %}

Or add the following meta-data tags to your `AndroidManifest.xml`:

{% code title="AndroidManifest.xml" %}

```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:name=".MainApplication"...>

        <!-- Whether Batch should automatically identify user when running the plugin v2 for the first time.-->
        <!-- This mean user with a custom_user_id will be automatically attached a to a Profile and could be targeted within a Project scope.-->
        <meta-data android:name="com.batch.flutter.profile_custom_id_migration_enabled" android:value="false"/>

        <!-- Whether Batch should automatically attach current installation's data (language/region/customDataAttributes...)-->
        <!-- to the User's Profile when running the plugin v2 for the first time.-->
        <meta-data android:name="com.batch.flutter.profile_custom_data_migration_enabled" android:value="false"/>
        ...
    </application>
</manifest>
```

{% endcode %}

**iOS**

You can programmatically update the plugin configuration from your `AppDelegate` class in the native `ios` directory by using :

```swift
// Whether Batch should automatically identify user when running the plugin v2 for the first time.
// This mean user with a custom_user_id will be automatically attached a to a Profile and could be targeted within a Project scope.
BatchFlutterPlugin.configuration.profileCustomIdMigrationEnabled = false

// Whether Batch should automatically attach current installation's data (language/region/customDataAttributes...)
// to the User's Profile when running the plugin v2 for the first time.
BatchFlutterPlugin.configuration.profileCustomDataMigrationEnabled = false
```

{% hint style="info" %}
Remember to make modifications before calling the `setup` method since all configuration changes made after will not be applied.
{% endhint %}

Or add the following entries to your `Info.plist` :

{% code title="Info.plist" %}

```xml
<plist version="1.0">
  <dict>
    ...
    <!-- Whether Batch should automatically identify user when running the plugin v2 for the first time.-->
    <!-- This mean user with a custom_user_id will be automatically attached a to a Profile and could be targeted within a Project scope.-->
    <key>BatchFlutterProfileCustomIdMigrationEnabled</key>
    <false/>
    <!-- Whether Batch should automatically attach current installation's data (language/region/customDataAttributes...)-->
    <!-- to the User's Profile when running the plugin v2 for the first time.-->
    <key>BatchFlutterProfileCustomDataMigrationEnabled</key>
    <false/>
  </dict>
</plist>
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.batch.com/developer/sdk/flutter/profile-data/data-migration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
