SqliteSchemaMigration

Non-destructive schema migration shared by every SQLite database in the SDK.

SDK updates (and rollbacks to a version that already has this migration) keep the data in every SDK database: the unsent upload queue, the map cache, the user's favourites and recently viewed places, location-marketing campaign state, property metadata, diagnostics and map overlays.

How it works, per database: the version is a constant LEGACY_VERSION_CODE_CEILING + revision that changes only when a table's CREATE SQL changes, and onUpgrade/onDowngrade call reconcileColumns for each table (rows kept) and then onCreate (CREATE TABLE IF NOT EXISTS for any table that was missing).

Types

Link copied to clipboard
enum Result
Outcome of reconcileColumns.

Properties

Link copied to clipboard
Every DB already on a phone carries the VERSION_CODE of the SDK that last opened it: YY*1_000_000 + M*10_000 + V*1_000 (26.x, mapsted-version.gradle.kts) or the same formula over MAJOR.MINOR.REVISION (legacy 6.x).

Functions

Link copied to clipboard
open fun keepRows(@NonNull db: SQLiteDatabase, @NonNull dbName: String, oldVersion: Int, newVersion: Int, @NonNull createSqls: Array<String>)
Migrate every table of a DB without losing rows, for helpers whose own code cannot work with a table left in an older shape.
Link copied to clipboard
Bring an existing table's columns in line with createSql while keeping its rows.