You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DataConnectCacheDatabaseMigrator.kt, DataConnectCacheDatabaseMigratorUnitTest.kt: Improve schema version error handling
Improves the developer experience by providing more detailed and helpful
error messages when the database schema version is invalid or not set.
This change helps prevent potential data corruption by aborting migrations
on databases with unknown schema versions.
### Changes
* DataConnectCacheDatabaseMigrator.kt:
* Updated the exception messages for invalid or null schema versions to be more descriptive.
* DataConnectCacheDatabaseMigratorUnitTest.kt:
* Added unit tests to verify that an `InvalidSchemaVersionException` is thrown for unknown schema versions.
* Added a unit test to verify that an `InvalidSchemaVersionException` is thrown for a null schema version.
Copy file name to clipboardExpand all lines: firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/sqlite2/DataConnectCacheDatabaseMigrator.kt
+10-2Lines changed: 10 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -183,7 +183,11 @@ private constructor(private val sqliteDatabase: SQLiteDatabase, private val logg
183
183
// The PATCH version changes for all other non-schema-affecting changes, such as adding an
184
184
// index to an existing table.
185
185
returnif (schemaVersion ===null) {
186
-
throwInvalidSchemaVersionException("schema_version is null")
186
+
throwInvalidSchemaVersionException(
187
+
"schema_version is null or not set;"+
188
+
" expected a value that starts with \"1.\";"+
189
+
" aborting to avoid corrupting the contents of the database"
Copy file name to clipboardExpand all lines: firebase-dataconnect/src/test/kotlin/com/google/firebase/dataconnect/sqlite2/DataConnectCacheDatabaseMigratorUnitTest.kt
0 commit comments