HI,
swiftdata is new to me and any help would be appreciated.
In my swiftui app I have a functionality that reinstates the database from an archive.
I first move the three database files (database.store datebase.store-wal and database.store-shm) to a new name (.tmp added for backup incase) and then copy the Archived three files to the same location.
the move creates the following errors:
" BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode renamed while in use: /private/var/mobile/Containers/Data/Application/499A6802-02E5-4547-83C4-88389AEA50F5/Library/Application Support/database.store.tmp
invalidated open fd: 4 (0x20)"
I get the same message in console for all three files.
then I reinitialise the model container and get no errors as my code below
....
let schema = Schema([....my different models are here])
let config = ModelConfiguration("database", schema: schema)
do {
// Recreate the container with the same store URL
let container = try ModelContainer(for: schema, configurations: config)
print("ModelContainer reinitialized successfully!")
} catch {
print("Failed to reinitialize ModelContainer: (error)")
}
}
I get the success message but when I leave the view (backup-restore view) to the main view I get:
CoreData: error: (6922) I/O error for database at /var/mobile/Containers/Data/Application/499A6802-02E5-4547-83C4-88389AEA50F5/Library/Application Support/database.store. SQLite error code:6922, 'disk I/O error'
and
error: SQLCore dispatchRequest: exception handling request: <NSSQLFetchRequestContext: 0x302920460> , I/O error for database at /var/mobile/Containers/Data/Application/499A6802-02E5-4547-83C4-88389AEA50F5/Library/Application Support/database.store. SQLite error code:6922, 'disk I/O error' with userInfo of {
NSFilePath = "/var/mobile/Containers/Data/Application/499A6802-02E5-4547-83C4-88389AEA50F5/Library/Application Support/database.store";
NSSQLiteErrorDomain = 6922;
}
error: -executeRequest: encountered exception = I/O error for database at /var/mobile/Containers/Data/Application/499A6802-02E5-4547-83C4-88389AEA50F5/Library/Application Support/database.store. SQLite error code:6922, 'disk I/O error' with userInfo = {
NSFilePath = "/var/mobile/Containers/Data/Application/499A6802-02E5-4547-83C4-88389AEA50F5/Library/Application Support/database.store";
NSSQLiteErrorDomain = 6922;
}
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLFetchRequestContext: 0x302920460> , I/O error for database at /var/mobile/Containers/Data/Application/499A6802-02E5-4547-83C4-88389AEA50F5/Library/Application Support/database.store. SQLite error code:6922, 'disk I/O error' with userInfo of {
NSFilePath = "/var/mobile/Containers/Data/Application/499A6802-02E5-4547-83C4-88389AEA50F5/Library/Application Support/database.store";
NSSQLiteErrorDomain = 6922;
}
Can anyone let me know how I should go about this - reseting the database from old backup files by copying over them.
or if there is a way to stop the database and restart it with the new files in swiftdata
my app is an ios app for phone and ipad