From ac37483d4754e58e6a3276ba9228b8bde91d5e79 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Wed, 13 May 2020 19:43:14 +0200 Subject: [PATCH] Fix for #1391 (kobo sync errors out if read/unread books had been present in app.db during initial database migration) --- cps/ub.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cps/ub.py b/cps/ub.py index 87af1e89..f5d0f28a 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -494,6 +494,10 @@ def migrate_Database(session): conn.execute("ALTER TABLE book_read_link ADD column 'last_time_started_reading' DATETIME") conn.execute("ALTER TABLE book_read_link ADD column 'times_started_reading' INTEGER DEFAULT 0") session.commit() + test = session.query(ReadBook).filter(ReadBook.last_modified == None).all() + for book in test: + book.last_modified = datetime.datetime.utcnow() + session.commit() try: session.query(exists().where(Shelf.uuid)).scalar() except exc.OperationalError: @@ -552,6 +556,7 @@ def migrate_Database(session): conn.execute("ALTER TABLE user ADD column `allowed_tags` String DEFAULT ''") conn.execute("ALTER TABLE user ADD column `denied_column_value` DEFAULT ''") conn.execute("ALTER TABLE user ADD column `allowed_column_value` DEFAULT ''") + session.commit() if session.query(User).filter(User.role.op('&')(constants.ROLE_ANONYMOUS) == constants.ROLE_ANONYMOUS).first() \ is None: create_anonymous_user(session)