# 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 SDK v1 and is already attached to a Project : migrations will be triggered on the first start running on SDK v2.
* Your app is running on the SDK 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 before starting the SDK:

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

```swift
import Batch

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
    // Disable profile's migration
    BatchSDK.setDisabledMigrations([
     
       // Whether Batch should automatically identify logged-in user when running the SDK 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.
       .customID,
       
       // Whether Batch should automatically attach current installation's data (language/region/customDataAttributes...)
       // to the User's Profile when running the SDK for the first time.
       .customData
     ])
    // Then start Batch SDK.
    BatchSDK.start(withAPIKey: "YOUR_API_KEY")
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
@import Batch;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      // Disable profile's migration
      [BatchSDK setDisabledMigrations: 
        // Whether Batch should automatically identify logged-in user when running the SDK 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.
        BatchMigrationCustomID |
        // Whether Batch should automatically attach current installation's data (language/region/customDataAttributes...)
        // to the User's Profile when running the SDK for the first time.
        BatchMigrationCustomData
      ];
  
  // Then start Batch SDK.
  [BatchSDK startWithAPIKey:@"MY_API_KEY"];

  return YES;
}
```

{% endtab %}
{% endtabs %}
