migrate

abstract suspend fun migrate(currentData: T): T(source)

Perform the migration. Implementations should be idempotent since this may be called multiple times. If migrate fails, DataStore will not commit any data to disk, cleanUp will not be called, and the exception will be propagated back to the DataStore call that triggered the migration. Future calls to DataStore will result in DataMigrations being attempted again. This method may be run multiple times when any failure is encountered.

Note that this will always be called before a call to cleanUp.

Note that accessing any data from DataStore directly from inside this function will result in deadlock, since DataStore doesn't return data until all migrations complete.

Return

The migrated data.

Parameters

currentData

the current data (it might be populated from other migrations or from manual changes before this migration was added to the app)