# AutoMigrationSpec

Artifact: [androidx.room:room-runtime](https://developer.android.com/jetpack/androidx/releases/room) [View Source](https://cs.android.com/search?q=file:androidx/room/migration/AutoMigrationSpec.+class:androidx.room.migration.AutoMigrationSpec) Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/room#2.4.0)

*** ** * ** ***


```
public interface AutoMigrationSpec
```

<br />

*** ** * ** ***

Interface for defining an automatic migration specification for Room databases.

The functions defined in this interface will be called on a background thread from the executor set in Room's builder. It is important to note that the functions are all in a transaction when it is called.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/room/AutoMigration` |   |

## Summary

| ### Public methods |
|---|---|
| `default void` | `https://developer.android.com/reference/androidx/room/migration/AutoMigrationSpec#onPostMigrate(androidx.sqlite.SQLiteConnection)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteConnection connection)` Invoked after the migration is completed. |
| `default void` | `https://developer.android.com/reference/androidx/room/migration/AutoMigrationSpec#onPostMigrate(androidx.sqlite.db.SupportSQLiteDatabase)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteDatabase db)` Invoked after the migration is completed. |

## Public methods

### onPostMigrate

Added in [2.7.0](https://developer.android.com/jetpack/androidx/releases/room#2.7.0)

```
default void onPostMigrate(@NonNull SQLiteConnection connection)
```

Invoked after the migration is completed.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteConnection connection` | The database connection. |

### onPostMigrate

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/room#2.4.0)

```
default void onPostMigrate(@NonNull SupportSQLiteDatabase db)
```

Invoked after the migration is completed.

This function is only called when Room is configured without a driver. If a driver is set using `https://developer.android.com/reference/androidx/room/RoomDatabase.Builder#setDriver(androidx.sqlite.SQLiteDriver)`, then only the version that receives a `https://developer.android.com/reference/androidx/sqlite/SQLiteConnection` is called.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteDatabase db` | The SQLite database. |