Database is not recreated in Xcode Previews #503
pro100filipp
started this conversation in
General
Replies: 1 comment 1 reply
|
Hi @pro100filipp, this is just how previews work. They can execute multiple times in the same process. To work around this fact you can use stable IDs for all of your seed data and perform Since this isn't an issue with the library I am going to convert it to a discussion. Please feel free to continue the conversation over there! |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Description
When using it in preview, it seems the database is preserved between preview runs, not recreated anew. It clearly exists in memory (not on disk), and the context shows we are inside the preview.
This is evident because when the preview is run again, the console shows a unique constraint violation error on the table. In other words, the database already exists and contains the corresponding record.
Checklist
mainbranch of this package.Expected behavior
I expect that, similar to SwiftData, if we use an in-memory database, it will be recreated each time we run the preview.
Actual behavior
The database exists and is not recreated.
Reproducing project
SqliteDataPreview.zip
SQLiteData version information
1.6.1
Sharing version information
2.8.0
GRDB version information
7.10.0
Destination operating system
iOS 26
Xcode version information
Version 26.4
Swift Compiler version information
All reactions