https://kotlinlang.org logo
s

Samuel Ochuba

06/14/2023, 7:26 PM
Copy code
fun createDatabase(driverFactory: DriverFactory,
                   migration1to2: Migration1to2,
                   migration2to3: Migration2to3): MultiplatformDb {
    val driver = driverFactory.createDriver()
    // Do more work with the database (see below).

    println(" the current version is ${MultiplatformDb.Schema.version}") // prints:  the current version is 5
    MultiplatformDb.Schema.migrateWithCallbacks(
        driver = driver,
        oldVersion = 0,
        newVersion = OrdaMultiplatformDb.Schema.version,
        AfterVersion(2) {
            migration1to2.execute(driver)
        },
        AfterVersion(3) {
            migration2to3.execute(driver)
        }
    )
    return MultiplatformDb(driver)
}
Hi . i noticed that everytime i kill and open the app the migration code is executed even though it has executed before . is there a way to enforce that the migration occurs only once ? i am using sqldelight for database