Tried to upgrade from version 4.3.4 to 4.5.8 and as soon as I log in Codebook crashes. Below is the terminal output:
Last login: Thu Sep 22 11:56:18 on ttys000
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
/Applications/Codebook.app/Contents/MacOS/Codebook ; exit;
Rolims-MacBook-Air:~ Rolly$ /Applications/Codebook.app/Contents/MacOS/Codebook ; exit;
2022-09-22 12:27:06.205 Codebook[1765:29548] +[NSSavePanel _warmUp] attempted warmup
2022-09-22 12:27:43.091 Codebook[1765:29587] Upgrading databases, found old version 20
2022-09-22 12:27:43.093 Codebook[1765:29587] *** Terminating app due to uncaught exception 'SQLCipherManagerCommandException', reason: 'duplicate column name: created_at'
*** First throw call stack:
0 CoreFoundation 0x00007fff2054dbfb __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff20286d92 objc_exception_throw + 48
2 ZTDataModel 0x0000000108d6771e -[SQLCipherManager execute:error:] + 0
3 CoreCodebook 0x000000010897fba3 -[StripSchemaManager migrateToSchemaFromVersion:toVersion:] + 8594
4 Codebook 0x000000010881b38e Codebook + 414606
5 ZTDataModel 0x0000000108d64f8c -[SQLCipherManager openDatabaseWithOptions:cipher:iterations:withHMAC:pageSize:kdfAlgo:hmacAlgo:license:] + 1399
6 ZTDataModel 0x0000000108d64a0c -[SQLCipherManager openDatabaseWithOptions:cipher:iterations:withHMAC:pageSize:kdfAlgo:license:] + 47
7 ZTDataModel 0x0000000108d649d4 -[SQLCipherManager openDatabaseWithOptions:cipher:iterations:withHMAC:pageSize:license:] + 29
8 ZTDataModel 0x0000000108d649ae -[SQLCipherManager openDatabaseWithOptions:cipher:iterations:withHMAC:license:] + 22
9 ZTDataModel 0x0000000108d64730 -[SQLCipherManager openDatabaseWithPassword:license:] + 118
10 ZTDataModel 0x0000000108d6b513 -[SQLCipherManager(Codebook) openCodebookDatabaseWithPassword:] + 51
11 Codebook 0x000000010880389f Codebook + 317599
12 libdispatch.dylib 0x00007fff20230623 _dispatch_call_block_and_release + 12
13 libdispatch.dylib 0x00007fff20231806 _dispatch_client_callout + 8
14 libdispatch.dylib 0x00007fff20240976 _dispatch_root_queue_drain + 676
15 libdispatch.dylib 0x00007fff20240f70 _dispatch_worker_thread2 + 92
16 libsystem_pthread.dylib 0x00007fff203d8417 _pthread_wqthread + 244
17 libsystem_pthread.dylib 0x00007fff203d742f start_wqthread + 15
libc++abi: terminating with uncaught exception of type NSException
Abort trap: 6
...copying shared history...
...saving history...truncating history files...
Any ideas on how to resolve this?
Hi @rollypolly, sorry about that! We should be able to fix this problem, but it requires a little investigation.
This error usually occurs after after upgrading to a newer version of Codebook that changes the database structure, then downgrading to an older version, and upgrading again some time after that.
Older versions of Codebook, upon encountering a newer database, would overwrite the schema version in the database on down-grade, marking it as having the older schema, improperly (it no longer does this!) Then when the user goes to upgrade again, Codebook attempts to re-apply the database changes that have already been applied, causing errors like the one above.
So what we need to know is if you upgraded and then downgraded at some point, and if so, do you remember what version it was that you had upgraded to, that didn’t work out for you? If not, we can figure it out by inspecting the database directly, I will post directions for doing that. Once we determine what the schema version should be for your current database, we can then set it directly, which should allow Codebook to resume working as expected.
I tried to upgrade to 4.4.0 a while ago with the same result but didn’t bother reporting it.
Got it, thanks!
It sounds like your schema version in the database should be set to 23 and not 20, assuming the crash on launch of 4.4.0 was related to something else, and those database migrations were in fact run.
So I think the best way to proceed is to use the free tool DB Browser to open up the encrypted database, check on the state of the structure to confirm, and set the correct schema number.
Download and launch DB Browser for SQLite on your Mac: https://sqlitebrowser.org
Switch back to Finder and click on the Go menu in the menu bar and then click on “Go to Folder…”
In the dialog that appears, paste this path (all one line):
Right-click (or hold down the command key and click) on the file named
default.strip and select Show Package Contents from the menu
Click and drag the file named
strip.db onto the DB Browser window (or onto the icon in your Dock)
DB Browser will prompt you for a password, enter the Master Password you use for Codebook
At this point you should be shown the Database Structure tab, listing all the tables in your encrypted database.
Let’s check the following to make sure we’ve got the right version:
- Click the arrow icon next to the
binaries table, and check that
updated_at are in the list of columns
- Click the arrow icon next to the
thumbnails table, and check that it also has columns named
- Expand the table named
zetetic_sync and check that it does NOT have a column named
If all those things are true, we are looking at schema 23, and we can now set that using DB Browser:
Click on the “Execute SQL” tab
In the editor that appears, enter this command:
PRAGMA user_version = '23';
Then click the play button to run the command, and look for
Execution finished without errors. in the output below
Close DB Browser
Launch the latest version of Codebook for macOS (4.5.8) and attempt to sign in again
I realize that’s a lot of steps, but it should do the trick. Could you give it a try, and let us know how it goes, or if things break down at any step along the way?
Thanks for the prompt help!
Great, I’m glad to hear that worked!
Sorry again for all the trouble you’ve experienced with upgrades. Now that you’re on the latest version things should be smoother from here on out (including software updates). If you have any other questions or problems please let us know.