Considering the altered database structure

fixing #2
This commit is contained in:
Martin Brodbeck 2021-03-29 15:19:03 +02:00
parent ad179ac9e0
commit 2fcb2ac3e7
1 changed files with 18 additions and 5 deletions

View File

@ -86,11 +86,24 @@ fn remove_ghost_books_from_db(tx: &Transaction) -> usize {
NO_PARAMS, NO_PARAMS,
) )
.unwrap(); .unwrap();
tx.execute(
r#"DELETE FROM books_uids WHERE book_id NOT IN ( SELECT id FROM books_impl )"#, let version: i32 = tx
NO_PARAMS, .query_row(r#"SELECT id FROM version"#, NO_PARAMS, |r| r.get(0))
) .unwrap();
.unwrap(); if version >= 37 {
tx.execute(
r#"DELETE FROM books_fast_hashes WHERE book_id NOT IN ( SELECT id FROM books_impl )"#,
NO_PARAMS,
)
.unwrap();
} else {
tx.execute(
r#"DELETE FROM books_uids WHERE book_id NOT IN ( SELECT id FROM books_impl )"#,
NO_PARAMS,
)
.unwrap();
}
tx.execute( tx.execute(
r#"DELETE FROM bookshelfs_books WHERE bookid NOT IN ( SELECT id FROM books_impl )"#, r#"DELETE FROM bookshelfs_books WHERE bookid NOT IN ( SELECT id FROM books_impl )"#,
NO_PARAMS, NO_PARAMS,