[PR #3417] [MERGED] Add: series migration to be unique #3967

Closed
opened 2026-04-25 00:17:45 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/3417
Author: @nichwall
Created: 9/14/2024
Status: Merged
Merged: 10/12/2024
Merged by: @advplyr

Base: masterHead: series_cleanup_2


📝 Commits (10+)

  • 2711b98 Add: series migration to be unique
  • c163f84 Update migration changelog for series name unique
  • bedba39 Merge branch 'master' into series_cleanup_2
  • 8ae62da Update migration unit test name
  • 868659a Add: unique constraint on bookseries table
  • fa451f3 Add: tests for one book in duplicate series
  • 999ada0 Fix: missing variables
  • 836d772 Update: remove the same book if occurs multiple times in duplicate series
  • 691ed88 Add more logging, clean up typo
  • 8b95dd6 Fix: test cases checking the wrong bookSeriesId

📊 Changes

6 files changed (+553 additions, -9 deletions)

View changed files

📝 server/managers/MigrationManager.js (+1 -2)
📝 server/migrations/changelog.md (+3 -3)
server/migrations/v2.15.0-series-column-unique.js (+206 -0)
📝 server/models/Series.js (+6 -0)
📝 test/server/managers/MigrationManager.test.js (+2 -4)
test/server/migrations/v2.15.0-series-column-unique.test.js (+335 -0)

📄 Description

This PR resolves https://github.com/advplyr/audiobookshelf/issues/3207 and is a continuation of https://github.com/advplyr/audiobookshelf/pull/3326.

A migration script is added for 2.13.5, so it will work for both a minor and patch release (not sure what the plans are for the next release). I added some unit tests for this migration, but also tested it manually before writing the unit tests. I also updated the Series model to have an index for series name and libraryId, because series can have the same name in different libraries.

I am not sure if I did the QueryInterface parts of the migration script correctly, so if y'all can check it that would be great. Basically, I am using raw SQL instead of Sequelize, so I'm not sure if this is the correct way to do things.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/3417 **Author:** [@nichwall](https://github.com/nichwall) **Created:** 9/14/2024 **Status:** ✅ Merged **Merged:** 10/12/2024 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `series_cleanup_2` --- ### 📝 Commits (10+) - [`2711b98`](https://github.com/advplyr/audiobookshelf/commit/2711b989e153669aaf869521ebbc0e9f006834ef) Add: series migration to be unique - [`c163f84`](https://github.com/advplyr/audiobookshelf/commit/c163f84aec65da8de7d31390e100d83dff86312a) Update migration changelog for series name unique - [`bedba39`](https://github.com/advplyr/audiobookshelf/commit/bedba39af9254e06f09c1e9ceaca3c1c813247fd) Merge branch 'master' into series_cleanup_2 - [`8ae62da`](https://github.com/advplyr/audiobookshelf/commit/8ae62da1389cd4fe87ba4327e9d76a66237b087a) Update migration unit test name - [`868659a`](https://github.com/advplyr/audiobookshelf/commit/868659a2f1260d350694ffeda0d59c58d2aa2769) Add: unique constraint on bookseries table - [`fa451f3`](https://github.com/advplyr/audiobookshelf/commit/fa451f362b0a83390bbe9dbc3b30abea0af21d8d) Add: tests for one book in duplicate series - [`999ada0`](https://github.com/advplyr/audiobookshelf/commit/999ada03d16fd5b6faf387c757c454e74dcb50a6) Fix: missing variables - [`836d772`](https://github.com/advplyr/audiobookshelf/commit/836d772cd4502f109a06d8c78f824a03bad0d249) Update: remove the same book if occurs multiple times in duplicate series - [`691ed88`](https://github.com/advplyr/audiobookshelf/commit/691ed88096082a42f30e077c0f3c3170c84ab5af) Add more logging, clean up typo - [`8b95dd6`](https://github.com/advplyr/audiobookshelf/commit/8b95dd65d917fe2c2b200918362b308f2514d6ee) Fix: test cases checking the wrong bookSeriesId ### 📊 Changes **6 files changed** (+553 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `server/managers/MigrationManager.js` (+1 -2) 📝 `server/migrations/changelog.md` (+3 -3) ➕ `server/migrations/v2.15.0-series-column-unique.js` (+206 -0) 📝 `server/models/Series.js` (+6 -0) 📝 `test/server/managers/MigrationManager.test.js` (+2 -4) ➕ `test/server/migrations/v2.15.0-series-column-unique.test.js` (+335 -0) </details> ### 📄 Description This PR resolves https://github.com/advplyr/audiobookshelf/issues/3207 and is a continuation of https://github.com/advplyr/audiobookshelf/pull/3326. A migration script is added for `2.13.5`, so it will work for both a minor and patch release (not sure what the plans are for the next release). I added some unit tests for this migration, but also tested it manually before writing the unit tests. I also updated the `Series` model to have an index for series name and libraryId, because series can have the same name in different libraries. I am not sure if I did the QueryInterface parts of the migration script correctly, so if y'all can check it that would be great. Basically, I am using raw SQL instead of Sequelize, so I'm not sure if this is the correct way to do things. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:17:45 +02:00
adam closed this issue 2026-04-25 00:17:45 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3967