Calibre v9 broke my calibre-web server
Posted in daily
Tags :I use calibre to manage my e-books, and I’ve setup a docker container on my Synology to serve them to my friends and family via calibre-web. Everything has been running smoothly for the last year or so.
Calibre got updated to version 9 today, and it turned out I had a few books to add to my library. I updated without a second thought, as all previous updates didn’t cause a hitch. What could possibly go wrong…?
I use an rsync script to update the database on my Synology, and today my calibre-web server broke. No books were displayed anymore, and all sidebar sorting links (categories, series, authors, etc.), generated an internal 500 error on the server:
sqlite3.OperationalError: no such column: books.isbn
It looked like a database schema mismatch.
I diffed my metadata.db with the sample file provided by calibre-web, and sure enough, 2 columns were missing (isbn and lccn) in the metadata.db file I had just tranferred.
This is how I checked if the column was missing:
docker exec -it calibre-web sh -lc 'sqlite3 /books/metadata.db ".schema books" | head -n 50'
Needless to say, I thought I was responsible for breaking something along the way, so I reinstalled a fresh container (v0.6.25) multiple times to no avail.
I ended up by posting a comment in an open issue on GitHub “Server error after updating calibre desktop version to 9.0. (Mac OS)”.
A temporary fix was suggested by uriel1998 that I applied to my container with the following docker command:
docker run --rm -it -v "/volume1/web/books:/books" nouchka/sqlite3 /books/metadata.db "ALTER TABLE books ADD COLUMN isbn INTEGER; ALTER TABLE books ADD COLUMN flags ANY;"
As long as I don’t run my rsync script, this will do the trick waiting for a fix.
Warning: don’t do this on your main metadata.db file, only on a copy.
21:50 Update
the database schema changed slightly with Calibre v9, some columns, which were previously unused anyway, got removed, and this is what broke calibre-web.
Kovid Goyal explains it here: https://www.mobileread.com/forums/showpost.php?p=4563776&postcount=2
