3

I was just trying out Sqldelight on Android but can't seem to figure out an easy way to just drop and recreate the db on device when I've modified a table (or even added / deleted a new table).

The docs seems to indicate we need to create a <prev_version_number>.sqm file, which I did but just left it empty as I'd like to drop / recreate the tables in code using the AndroidSqliteDriver.Callback shown below (I just added a println() to see if it gets invoked for now), however this does not seem to be getting called when I modify the table (and/or add/delete a new table).

        return AndroidSqliteDriver(
        schema = MyDatabase.Schema,
        context = application,
        name = "myDb.db",
        callback = AndroidSqliteDriver.Callback(
            schema = MyDatabase.Schema,
            AfterVersionWithDriver(0) { println("DB Callback 0: AfterVersionWithDriver($it)") },
            AfterVersionWithDriver(1) { println("DB Callback 1: AfterVersionWithDriver($it)") },
        )
    )

Does anyone know how I could get this code inside the callback to execute on a migration or when it will be called by sqldelight?

Thanks.

Bootstrapper
  • 1,089
  • 3
  • 14
  • 33

0 Answers0