[PR #3597] [MERGED] MediaId UUID migration #4030

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

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/3597
Author: @nichwall
Created: 11/9/2024
Status: Merged
Merged: 11/17/2024
Merged by: @advplyr

Base: masterHead: mediatype_uuid_migration


📝 Commits (3)

  • 713bdcb Add: migration for mediaId to use UUID instead of UUIDV4
  • 161a3f4 Update migrations changelog for 2.16.3
  • 2b7e3f0 Update uuid migration to v2.17.0 and for all tables still using UUIDv4

📊 Changes

8 files changed (+105 additions, -6 deletions)

View changed files

📝 server/migrations/changelog.md (+1 -0)
server/migrations/v2.17.0-uuid-replacement.js (+98 -0)
📝 server/models/Feed.js (+1 -1)
📝 server/models/LibraryItem.js (+1 -1)
📝 server/models/MediaItemShare.js (+1 -1)
📝 server/models/MediaProgress.js (+1 -1)
📝 server/models/PlaybackSession.js (+1 -1)
📝 server/models/PlaylistMediaItem.js (+1 -1)

📄 Description

This PR fixes https://github.com/advplyr/audiobookshelf/issues/2324.

This adds a migration to convert the mediaId column in the libraryItems table to be a UUID instead of a UUIDv4. After performing the migration on my test server, everything still seemed to be linked correctly between mediaProgress, libraryItem, books, and podcasts, where deleting a book did cascade correctly. I was also able to scan my library and saw new rows created correctly in each table.

The only performance difference I saw was in the noise (less than 3 ms difference on any given query).

I am a little hesitant about this change if anything goes wrong during the migration due to SQLite copying the table, creating a new table, then moving data over. From my reading, this can trigger delete cascades, but I did not experience that in my testing. Additional reading at https://sequelize.org/docs/v6/other-topics/query-interface/#changing-and-removing-columns-in-sqlite and https://stackoverflow.com/a/70486686


🔄 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/3597 **Author:** [@nichwall](https://github.com/nichwall) **Created:** 11/9/2024 **Status:** ✅ Merged **Merged:** 11/17/2024 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `mediatype_uuid_migration` --- ### 📝 Commits (3) - [`713bdcb`](https://github.com/advplyr/audiobookshelf/commit/713bdcbc419b6b5db9af68effd3b0984be93aa41) Add: migration for mediaId to use UUID instead of UUIDV4 - [`161a3f4`](https://github.com/advplyr/audiobookshelf/commit/161a3f4da925821d1f2ff41e0d9954291588a308) Update migrations changelog for 2.16.3 - [`2b7e3f0`](https://github.com/advplyr/audiobookshelf/commit/2b7e3f0efe6fae0d6138cb95ac72224f81b31bfc) Update uuid migration to v2.17.0 and for all tables still using UUIDv4 ### 📊 Changes **8 files changed** (+105 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `server/migrations/changelog.md` (+1 -0) ➕ `server/migrations/v2.17.0-uuid-replacement.js` (+98 -0) 📝 `server/models/Feed.js` (+1 -1) 📝 `server/models/LibraryItem.js` (+1 -1) 📝 `server/models/MediaItemShare.js` (+1 -1) 📝 `server/models/MediaProgress.js` (+1 -1) 📝 `server/models/PlaybackSession.js` (+1 -1) 📝 `server/models/PlaylistMediaItem.js` (+1 -1) </details> ### 📄 Description This PR fixes https://github.com/advplyr/audiobookshelf/issues/2324. This adds a migration to convert the `mediaId` column in the `libraryItems` table to be a UUID instead of a UUIDv4. After performing the migration on my test server, everything still seemed to be linked correctly between `mediaProgress`, `libraryItem`, `books`, and `podcasts`, where deleting a book did cascade correctly. I was also able to scan my library and saw new rows created correctly in each table. The only performance difference I saw was in the noise (less than 3 ms difference on any given query). I am a little hesitant about this change if anything goes wrong during the migration due to SQLite copying the table, creating a new table, then moving data over. From my reading, this can trigger delete cascades, but I did not experience that in my testing. Additional reading at https://sequelize.org/docs/v6/other-topics/query-interface/#changing-and-removing-columns-in-sqlite and https://stackoverflow.com/a/70486686 --- <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:18:02 +02:00
adam closed this issue 2026-04-25 00:18:02 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4030