mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-01 00:18:14 +01:00
Update clean database to remove invalid CollectionBook records
This commit is contained in:
parent
0fbba3efbd
commit
95864705dc
@ -700,6 +700,7 @@ class Database {
|
||||
await libraryItem.destroy()
|
||||
}
|
||||
|
||||
// Remove invalid PlaylistMediaItem records
|
||||
const playlistMediaItemsWithNoMediaItem = await this.playlistMediaItemModel.findAll({
|
||||
include: [
|
||||
{
|
||||
@ -721,6 +722,19 @@ class Database {
|
||||
await playlistMediaItem.destroy()
|
||||
}
|
||||
|
||||
// Remove invalid CollectionBook records
|
||||
const collectionBooksWithNoBook = await this.collectionBookModel.findAll({
|
||||
include: {
|
||||
model: this.bookModel,
|
||||
required: false
|
||||
},
|
||||
where: { '$book.id$': null }
|
||||
})
|
||||
for (const collectionBook of collectionBooksWithNoBook) {
|
||||
Logger.warn(`Found collectionBook with no book - removing it`)
|
||||
await collectionBook.destroy()
|
||||
}
|
||||
|
||||
// Remove empty series
|
||||
const emptySeries = await this.seriesModel.findAll({
|
||||
include: {
|
||||
|
Loading…
Reference in New Issue
Block a user