mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-20 19:05:00 +02:00
Update clean database to remove invalid CollectionBook records
This commit is contained in:
parent
0fbba3efbd
commit
95864705dc
1 changed files with 14 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue