Migrator

public abstract class Migrator
extends Object

java.lang.Object
   ↳ androidx.appsearch.app.Migrator


A migrator class to translate GenericDocument from different version of AppSearchSchema

Make non-backwards-compatible changes will delete all stored documents in old schema. You can save your documents by setting Migrator via the SetSchemaRequest.Builder.setMigrator(String, Migrator) for each type and target version you want to save.

onDowngrade(int, int, GenericDocument) or onUpgrade(int, int, GenericDocument) will be triggered if the version number of the schema stored in AppSearch is different with the version in the request.

If any error or Exception occurred in the onDowngrade(int, int, GenericDocument) or onUpgrade(int, int, GenericDocument), all the setSchema request will be rejected unless the schema changes are backwards-compatible, and stored documents won't have any observable changes.

Summary

Public constructors

Migrator()

Public methods

abstract GenericDocument onDowngrade(int currentVersion, int finalVersion, GenericDocument document)

Migrates GenericDocument to an older version of AppSearchSchema.

abstract GenericDocument onUpgrade(int currentVersion, int finalVersion, GenericDocument document)

Migrates GenericDocument to a newer version of AppSearchSchema.

abstract boolean shouldMigrate(int currentVersion, int finalVersion)

Returns true if this migrator's source type needs to be migrated to update from currentVersion to finalVersion.

Inherited methods