# 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)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOS
- Cmn

  ```
  interface AutoMigrationSpec
  ```

*** ** * ** ***

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/kotlin/androidx/room/AutoMigration` |   |

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/migration/AutoMigrationSpec#onPostMigrate(androidx.sqlite.SQLiteConnection)(connection: https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteConnection)` Invoked after the migration is completed. | Cmn android N |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/migration/AutoMigrationSpec#onPostMigrate(androidx.sqlite.db.SupportSQLiteDatabase)(db: https://developer.android.com/reference/kotlin/androidx/sqlite/db/SupportSQLiteDatabase)` Invoked after the migration is completed. | android |

## Public functions

### onPostMigrate

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

```
fun onPostMigrate(connection: SQLiteConnection): Unit
```

Invoked after the migration is completed.

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

### onPostMigrate

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

```
open fun onPostMigrate(db: SupportSQLiteDatabase): Unit
```

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/kotlin/androidx/room/RoomDatabase.Builder#setDriver(androidx.sqlite.SQLiteDriver)`, then only the version that receives a `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteConnection` is called.

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