mardi 29 septembre 2015

Copied CoreData sqlite3 file, but copy doesn't show any tables

I've got a very data sensitive app and just to be absolutely sure there is no data lost when app updates are made and the CoreData sqlite file is upgraded, we grab a copy of the CoreData .sqlite file and upload it to the server. That part appears to be working just fine. The file comes through exactly the same size and when I diff it with the original they are identical.

However, when I open the original .sqlite file and issue a .tables command, I see all of the appropriate tables, but when I open the copied .sqlite file and issue a .tables command I get nothing.

Using the directory associated with the simulator, I can use sqlite3 to check the original .sqlite file and the pre-upload copy of the file and I see all of the tables:

Kenny-iMac:~/Library/Developer/CoreSimulator/Devices/C9E435A0-F438-45B0-914A-0E586A12589B/data/Containers/Data/Application/0B0C4673-99AF-4EEF-A9BE-654C155BB167/Documents$ sqlite3 MyApp.sqlite
SQLite version 3.8.5 2014-08-15 22:37:57
Enter ".help" for usage hints.
sqlite> .tables
ZBASECLONABLEENTITY   ZREPORTCONFIGURATION  Z_MODELCACHE        
ZCHANGERECORD         Z_3LABELS             Z_PRIMARYKEY        
ZOWNER                Z_METADATA          
sqlite> .quit
Kenny-iMac:~/Library/Developer/CoreSimulator/Devices/C9E435A0-F438-45B0-914A-0E586A12589B/data/Containers/Data/Application/0B0C4673-99AF-4EEF-A9BE-654C155BB167/Documents$ sqlite3 backup.MyApp.v1.0-to-v1.1.3.1234567.sqlite 
SQLite version 3.8.5 2014-08-15 22:37:57
Enter ".help" for usage hints.
sqlite> .tables
ZBASECLONABLEENTITY   ZREPORTCONFIGURATION  Z_MODELCACHE        
ZCHANGERECORD         Z_3LABELS             Z_PRIMARYKEY        
ZOWNER                Z_METADATA          
sqlite> .quit
Kenny-iMac:~/Library/Developer/CoreSimulator/Devices/C9E435A0-F438-45B0-914A-0E586A12589B/data/Containers/Data/Application/0B0C4673-99AF-4EEF-A9BE-654C155BB167/Documents$ 

However, when I use sqlite3 on the uploaded file, I don't see any tables:

Kenny-iMac:~/Sites/http://ift.tt/1iZrV12 sqlite3 backup.MyApp.v1.0-to-v1.1.3.1234567.sqlite
SQLite version 3.8.5 2014-08-15 22:37:57
Enter ".help" for usage hints.
sqlite> .tables
sqlite> .quit
Kenny-iMac:~/Sites/http://ift.tt/1iZrV12

The filesize of the original and the backup file are the same (880640):

Kenny-Mac: [simulator directory] $ ls -l
total 3648
-rw-r--r--  1 kenny  staff  921600 Sep 29 08:52 MyApp.sqlite
-rw-r--r--  1 kenny  staff   32768 Sep 29 08:51 MyApp.sqlite-shm
-rw-r--r--  1 kenny  staff       0 Sep 29 08:52 MyApp.sqlite-wal
-rw-r--r--  1 kenny  staff  880640 Sep 24 16:00 backup.MyApp.v1.0-to-v1.1.3.1234567.sqlite
-rw-r--r--  1 kenny  staff   32768 Sep 29 11:12 backup.MyApp.v1.0-to-v1.1.3.1234567.sqlite-shm
-rw-r--r--  1 kenny  staff       0 Sep 29 08:52 backup.MyApp.v1.0-to-v1.1.3.1234567.sqlite-wal
Kenny-Mac: [simulator directory] $

The upload copy is the same size (880640):

Kenny-iMac:~/Sites/http://ift.tt/1Ww1v5g ls -l
total 1720
-rw-r--r--  1 _www  wheel  880640 Sep 29 08:44 backup.HerdBoss.v1.0-to-v1.1.3.1234567.sqlite.oid.0.unverified
Kenny-iMac:~/Sites/http://ift.tt/1Ww1v5g

I also compared them with diff and they are identical.

Why can't I see the tables in my backup copy?

Aucun commentaire:

Enregistrer un commentaire