# migrateToAccountScoped

> For the complete documentation index, see [llms.txt](https://docs.midnight.network/llms.txt)

[**Midnight.js API Reference v4.1.0**](https://docs.midnight.network/api-reference/midnight-js.md)

***

[Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages.md) / [@midnight-ntwrk/midnight-js-level-private-state-provider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider.md) / migrateToAccountScoped

# Function: migrateToAccountScoped()

> **migrateToAccountScoped**(`config`): `Promise`<[`MigrationResult`](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider/interfaces/MigrationResult.md)>

Migrates existing unscoped private state and signing key data to account-scoped sublevels.

This function copies data from the legacy unscoped locations to the new account-scoped locations. The original data is preserved (not deleted) to allow for safe rollback if needed. To remove old data after successful migration, manually clear the unscoped sublevels.

Note: Running this function multiple times is safe but will re-copy all data, overwriting any changes made in the scoped location since the last migration.

## Parameters[​](#parameters "Direct link to Parameters")

### config[​](#config "Direct link to config")

`Partial`<[`LevelPrivateStateProviderConfig`](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider/interfaces/LevelPrivateStateProviderConfig.md)> & `Pick`<[`LevelPrivateStateProviderConfig`](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider/interfaces/LevelPrivateStateProviderConfig.md), `"accountId"`>

## Returns[​](#returns "Direct link to Returns")

`Promise`<[`MigrationResult`](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider/interfaces/MigrationResult.md)>
