5.0 Migration Guide
This lists out the major changes since < 5.0
Major Changes
- 1.Package name is now
com.dbflow5
, which enables bundling multiple versions in the same repo.- 1.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.
- 2.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
-kotlinextensions
artifacts are not rolled within the library. - 3.Library now adds support for incremental annotation processing. Please report any issues!
- 4.New artifacts:
paging
(architecture components Paging),coroutines
,contentprovider
, (splits outContentProvider
usage out of main library),livedata
,reactive-streams
(RXJava3).- 1.
RXJava
1 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-streams
files you need and then replace the package names back to their RXJava2 equivalent. RXJava 1 is not quite equivalent and not supported.
- 5.
save()
methods on theModelAdapter
classes now use a more efficientINSERT OR REPLACE
method, rather than check ifexists
manually from the DB before inserting or replacing. - 6.
@Database
classes must now be an abstract class that extendsDBFlowDatabase
(or related subclass)- 1.@Database(version = 1)abstract class AppDatabase : DBFlowDatabase()
- 7.Removed deprecated
@Database
annotation fields includingname
,databaseExtension
, andinMemory
. Use theDatabaseConfig.Builder
object when initializing DBFlow. - 8.The implicit
DatabaseWrapper
that was used in model operations is now required explicit. - 9.// 4.x// this would grab the default database from the FlowManagermodel.save()// 5.xdatabase<AppDatabase> { db -> model.save(db) }
- 10.
ModelAdapter.bindToContentValues
and correspondingContentValues
generated code is no l longer enabled by default. If you need the methods, set@Table(generateContentValues = true)
. 1. For@ContentProvider
object, your db must now extendContentProviderDatabase
to supplyContentValues
methods on the database. - 11.Explicitly marking every field in a
@Table
with@Column
is no longer the default. By default any field in the model class are referenced. To enable the old behavior use@Table(allFields = false)
- 12.
- 13.
@ModelView
: getsorderedCursorLookup
,assignDefaultValuesFromCursor
, andcreateWithDatabase
that were allowed on@Table
classes.- 1.
@ModelViewQuery
can now be used on aProperty
- 14.
@QueryModel
: getsorderedCursorLookup
, andassignDefaultValuesFromCursor
that were allowed on@Table
classes. - 15.
IMultiKeyCacheConverter
renamed toMultiKeyCacheConverter
- 16.Performing 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()
- 17.
QueryModelAdapter
is deprecated asRetrievalAdapter
performs all functionality. - 18.DBFlowDatabase can now specify a
JournalMode
to support write-ahead logging. Note: on higher end devices this will enableWriteAheadLogging
by default. - 19.New
TableObserver
class on aDBFlowDatabase
. Inspired by Room, this sets upTrigger
on table changes for observed tables to efficiently track which table changes. This is useful in recomputing queries forLiveData
,Flowable
, orPaging
DataSource
. Whenever aTransaction
is run on the DB, upon completing it, we check for any table changes and dispatch that to the active queries that are observed.- 1.(select from MyTable::class ...).toLiveData(db).observe(owner) { r -> }
- 20.
AlterTableMigration
supports default values for a column when adding a column. - 21.
Index.enable
renamed tocreateIfNotExists
,Index.disable
renamed todrop
. - 22.Reduce generated code in tables.
Last modified 2yr ago