My application uses SQLDelight to save chat histor...
# squarelibraries
y
My application uses SQLDelight to save chat history and generated images. This functionality has suddenly stopped working (Everthing works before) . To ensure this wasn't a local issue, I completely deleted my local repository and cloned it again. The problem persists. The app fails with the following errors:
Copy code
text
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: chats)
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: generated_images)
To reproduce the error: 1. Clone the repository: https://github.com/yassineAbou/LLMS.git 2. Run the composeApp desktop target 3. The errors appear immediately during the build
j
Where is your code that creates the tables / performs migrations?
j
Yeah but when you create the database driver you need to conditionally create or migrate the schema for all platforms other than Android
Do you have code for that?
y
Is migration necessary even though I haven’t added anything new to the database?
j
Yes. It's empty otherwise
y
I added the migrateIfNeeded function. But I'm still getting the same errors. Here's the new code link: https://github.com/yassineAbou/LLMS/blob/master/composeApp/src/desktopMain/kotlin/[…]yassineabou/llms/app/core/data/local/DatabaseFactory.desktop.kt
If anyone would like to help or contribute, it would be greatly appreciated! 🙏
j
What do you see logged on startup?
When you inspect the database file do you see the tables?
y
I ran the debugger, but no table was created. Here's what the log shows: Info: DB version 1 is up to date.
j
If it read a version of 1, that means your code ran at some point and should have created the tables
y
The database works fine on Android as it is jvm based but fails on desktop. I doubt it's a migration problem.
j
Android is not JVM based, and as I said above, migrations are only automatic on Android and nowhere else.