mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Add: migration for mediaId to use UUID instead of UUIDV4
This commit is contained in:
parent
d7e810fc2f
commit
713bdcbc41
50
server/migrations/v2.16.3-uuid-replacement.js
Normal file
50
server/migrations/v2.16.3-uuid-replacement.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* @typedef MigrationContext
|
||||||
|
* @property {import('sequelize').QueryInterface} queryInterface - a suquelize QueryInterface object.
|
||||||
|
* @property {import('../Logger')} logger - a Logger object.
|
||||||
|
*
|
||||||
|
* @typedef MigrationOptions
|
||||||
|
* @property {MigrationContext} context - an object containing the migration context.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This upward migration script changes the `mediaId` column in the `libraryItems` table to be a UUID and match other tables.
|
||||||
|
*
|
||||||
|
* @param {MigrationOptions} options - an object containing the migration context.
|
||||||
|
* @returns {Promise<void>} - A promise that resolves when the migration is complete.
|
||||||
|
*/
|
||||||
|
async function up({ context: { queryInterface, logger } }) {
|
||||||
|
// Upwards migration script
|
||||||
|
logger.info('[2.16.3 migration] UPGRADE BEGIN: 2.16.3-uuid-replacement')
|
||||||
|
|
||||||
|
// Change mediaId column to using the query interface
|
||||||
|
logger.info('[2.16.3 migration] Changing mediaId column to UUID')
|
||||||
|
await queryInterface.changeColumn('libraryItems', 'mediaId', {
|
||||||
|
type: 'UUID'
|
||||||
|
})
|
||||||
|
|
||||||
|
// Completed migration
|
||||||
|
logger.info('[2.16.3 migration] UPGRADE END: 2.16.3-uuid-replacement')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This downward migration script changes the `mediaId` column in the `libraryItems` table to be a UUIDV4 again.
|
||||||
|
*
|
||||||
|
* @param {MigrationOptions} options - an object containing the migration context.
|
||||||
|
* @returns {Promise<void>} - A promise that resolves when the migration is complete.
|
||||||
|
*/
|
||||||
|
async function down({ context: { queryInterface, logger } }) {
|
||||||
|
// Downward migration script
|
||||||
|
logger.info('[2.16.3 migration] DOWNGRADE BEGIN: 2.16.3-uuid-replacement')
|
||||||
|
|
||||||
|
// Change mediaId column to using the query interface
|
||||||
|
logger.info('[2.16.3 migration] Changing mediaId column to UUIDV4')
|
||||||
|
await queryInterface.changeColumn('libraryItems', 'mediaId', {
|
||||||
|
type: 'UUIDV4'
|
||||||
|
})
|
||||||
|
|
||||||
|
// Completed migration
|
||||||
|
logger.info('[2.16.3 migration] DOWNGRADE END: 2.16.3-uuid-replacement')
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { up, down }
|
@ -1059,7 +1059,7 @@ class LibraryItem extends Model {
|
|||||||
ino: DataTypes.STRING,
|
ino: DataTypes.STRING,
|
||||||
path: DataTypes.STRING,
|
path: DataTypes.STRING,
|
||||||
relPath: DataTypes.STRING,
|
relPath: DataTypes.STRING,
|
||||||
mediaId: DataTypes.UUIDV4,
|
mediaId: DataTypes.UUID,
|
||||||
mediaType: DataTypes.STRING,
|
mediaType: DataTypes.STRING,
|
||||||
isFile: DataTypes.BOOLEAN,
|
isFile: DataTypes.BOOLEAN,
|
||||||
isMissing: DataTypes.BOOLEAN,
|
isMissing: DataTypes.BOOLEAN,
|
||||||
|
Loading…
Reference in New Issue
Block a user