SqlSchema

interface SqlSchema<T : QueryResult<Unit>>

API for creating and migrating a SQL database. The implementation of this interface is generated by SQLDelight.

Parameters

T

Says whether the generated code for this database is asynchronous or synchronous. Most implementations of app.cash.sqldelight.SqlDriver will require one or the other, which is enforced by requesting the correlated type of Schema (QueryResult.Value for a synchronous runtime, QueryResult.AsyncValue for asynchronous). In a multiplatform environment where you have some drivers that use an asynchronous runtime, and some that require synchronous, you can generate an asynchronous runtime and then pass a synchronous schema to synchronous drivers with SqlSchema.synchronous()

Properties

Link copied to clipboard
abstract val version: Long

The version of this schema.

Functions

Link copied to clipboard
abstract fun create(driver: SqlDriver): T

Use driver to create the schema from scratch. Assumes no existing database state.

Link copied to clipboard
abstract fun migrate(driver: SqlDriver, oldVersion: Long, newVersion: Long, vararg callbacks: AfterVersion): T

Use driver to migrate from schema oldVersion to newVersion. Each of the callbacks are executed during the migration whenever the upgrade to the version specified by AfterVersion.afterVersion has been completed.