[SQLDelight - ios only] Is it possible to ensure m...
# squarelibraries
k
[SQLDelight - ios only] Is it possible to ensure migrations are run before I try to access the DB? Use case: On app start in home screen, need to read data from db and display it. Seems like db is not migrated to next version and table is not yet created but I try to access it. 😞 Not sure how to ensure migrations are run before I access db? PS - Android seems to be okay ios is having issues. Logs in 🧵
e
Are you using the SqlDelight native driver? It looks like that's supposed to handle that for you.
k
ah yea! when creating the sql driver the migrations are run, so that should not be an issue.
Copy code
return NativeSqliteDriver(
    schema = KrailSandook.Schema,
    name = "krailSandook.db",
    callbacks = getMigrationCallbacks(),
)
(using IF NOT EXISTS in query and seems like I was missing space between ? when writing insert query.) After these changes seems like error for column has been fixed but facing another error now. > 2025-06-16 214908.228805+1000 Krail App[1046:29998] Metal API Validation Enabled > executeNonQuery error | error code SQLITE_BUSY > co.touchlab.sqliter.interop.SQLiteExceptionErrorCode: executeNonQuery error > 2025-06-16 214908.726071+1000 Krail App[1046:29998] fopen failed for data file: errno = 2 (No such file or directory) > 2025-06-16 214908.726126+1000 Krail App[1046:29998] Errors found! Invalidating cache... > 2025-06-16 214908.758410+1000 Krail App[1046:29998] fopen failed for data file: errno = 2 (No such file or directory) > 2025-06-16 214908.758457+1000 Krail App[1046:29998] Errors found! Invalidating cache... full log attached as file.
e
SQLITE_BUSY is related to concurrency https://www.sqlite.org/rescode.html#busy
👍 1
k
dumb Q: if a lib am using also is trying to access SQL DB at same time as the app, would it still result into SQLITE_BUSY. Or SQLITE_BUSY would happen only if the app has multiple threads trying to access DB ?
e
Yes it could result in SQLITE_BUSY
k
thansk! any ideas / things to keep in mind, to ensure this does not happen at app launch, e.g. i suspect firebase is trying to do something and i try to read data too. it happens only on ios and rarely though.