5.0 Migration Guide
This lists out the major changes since < 5.0
Major Changes
Package name is now
com.dbflow5, which enables bundling multiple versions in the same repo.Note: Using multiple versions of DBFlow on the same DB is not recommended, as it can lead to inconsistent usage on the database in respect to transaction queuing, migrations, or synchronization.
Library is now 100% Kotlin, except generated code. KSP (Kotlin Source Processing) is promising, but will require major updates to support it directly. This means that any
-kotlinextensionsartifacts are not rolled within the library.Library now adds support for incremental annotation processing. Please report any issues!
New artifacts:
paging(architecture components Paging),coroutines,contentprovider, (splits outContentProviderusage out of main library),livedata,reactive-streams(RXJava3).RXJava1 and 2 support is dropped given, https://github.com/ReactiveX/RxJava/tree/2.x is now in maintenance mode. You simply need to copy paste thereactive-streamsfiles you need and then replace the package names back to their RXJava2 equivalent. RXJava 1 is not quite equivalent and not supported.
save()methods on theModelAdapterclasses now use a more efficientINSERT OR REPLACEmethod, rather than check ifexistsmanually from the DB before inserting or replacing.@Databaseclasses must now be an abstract class that extendsDBFlowDatabase(or related subclass)@Database(version = 1) abstract class AppDatabase : DBFlowDatabase()
Removed deprecated
@Databaseannotation fields includingname,databaseExtension, andinMemory. Use theDatabaseConfig.Builderobject when initializing DBFlow.The implicit
DatabaseWrapperthat was used in model operations is now required explicit.// 4.x // this would grab the default database from the FlowManager model.save() // 5.x database<AppDatabase> { db -> model.save(db) }ModelAdapter.bindToContentValuesand correspondingContentValuesgenerated code is no l longer enabled by default. If you need the methods, set@Table(generateContentValues = true). 1. For@ContentProviderobject, your db must now extendContentProviderDatabaseto supplyContentValuesmethods on the database.Explicitly marking every field in a
@Tablewith@Columnis no longer the default. By default any field in the model class are referenced. To enable the old behavior use@Table(allFields = false)Adds
@Fts3and@Fts4annotations. See SQLite docs on Fts3 and 4.@ModelView: getsorderedCursorLookup,assignDefaultValuesFromCursor, andcreateWithDatabasethat were allowed on@Tableclasses.@ModelViewQuerycan now be used on aProperty
@QueryModel: getsorderedCursorLookup, andassignDefaultValuesFromCursorthat were allowed on@Tableclasses.IMultiKeyCacheConverterrenamed toMultiKeyCacheConverterPerforming DB operations not in a transaction will throw a new warning in
FlowLog:Database Not Running in a Transaction. Performance may be impacted, observability will need manual updates via db.tableObserver.checkForTableUpdates()QueryModelAdapteris deprecated asRetrievalAdapterperforms all functionality.DBFlowDatabase can now specify a
JournalModeto support write-ahead logging. Note: on higher end devices this will enableWriteAheadLoggingby default.New
TableObserverclass on aDBFlowDatabase. Inspired by Room, this sets upTriggeron table changes for observed tables to efficiently track which table changes. This is useful in recomputing queries forLiveData,Flowable, orPagingDataSource. Whenever aTransactionis run on the DB, upon completing it, we check for any table changes and dispatch that to the active queries that are observed.(select from MyTable::class ...) .toLiveData(db) .observe(owner) { r -> }
AlterTableMigrationsupports default values for a column when adding a column.Index.enablerenamed tocreateIfNotExists,Index.disablerenamed todrop.Reduce generated code in tables.
Last updated
Was this helpful?