https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
m

Myans

03/07/2024, 11:13 AM
Hi, is there a way to programmatically set the database max size for sqlidelight in multiplatform?
c

cb

03/07/2024, 3:24 PM
What does 'max size' mean here? Number of rows? Rows * columns? File size? If you're looking to emulate Android's
maximumSize
then you can just copy over the PRAGMA queries it uses and execute them against your driver: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/database/sqlite/SQLiteDatabase.java;l=1296
m

Myans

03/07/2024, 3:34 PM
File size. I found there's a callback that returning SupportSQLiteDatabase when creating the driver for each target. is it safe to assume I can set the size inside the callback?
Copy code
return AndroidSqliteDriver(
    schema = AppDatabase.Schema,
    context = argument as Context,
    name = "mylocal.db",
    callback = object : AndroidSqliteDriver.Callback(AppDatabase.Schema) {
        override fun onOpen(db: SupportSQLiteDatabase) {
            db.setForeignKeyConstraintsEnabled(true)
            db.setMaximumSize(1024)
        }
    }
)
something like this