Skip to content

Commit fbcd882

Browse files
committed
fix: ann_id removed
1 parent d023b68 commit fbcd882

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

lib/handlers/MBNDSynchronizer.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const fs = require('fs');
22
const csv2json = require('csvtojson');
33
const { Op } = require('sequelize');
4-
const { randomUUID } = require('crypto');
54
const pLimit = require('p-limit');
65
const camelCase = require('camelcase');
76
const dayjs = require('dayjs');
@@ -250,7 +249,6 @@ class MBNDSynchronizer {
250249
let annotation = foundTrack?.trackAnnotation;
251250
if (!annotation) {
252251
annotation = Annotation.build({
253-
ann_id: randomUUID(),
254252
item_type: 'media_file',
255253
user_id: user.id,
256254
item_id: foundTrack.id,
@@ -364,7 +362,6 @@ class MBNDSynchronizer {
364362
let annotation = album?.albumAnnotation;
365363
if (!annotation) {
366364
annotation = Annotation.build({
367-
ann_id: randomUUID(),
368365
item_type: 'album',
369366
user_id: user.id,
370367
item_id: album.id,
@@ -476,7 +473,6 @@ class MBNDSynchronizer {
476473
let annotation = artist?.artistAnnotation;
477474
if (!annotation) {
478475
annotation = Annotation.build({
479-
ann_id: randomUUID(),
480476
item_type: 'artist',
481477
user_id: user.id,
482478
item_id: artist.id,

lib/handlers/dbManager.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ const createRelationships = sequelize => {
4444
Annotation.belongsTo(Track, { as: 'track', foreignKey: 'item_id' });
4545
Annotation.belongsTo(Album, { as: 'album', foreignKey: 'item_id' });
4646
Annotation.belongsTo(User, { as: 'user', foreignKey: 'user_id' });
47+
// ann_id removed from navidrome DB schema in this commit: https://github.com/navidrome/navidrome/commit/47378c68828861751b9d1a05d3fc9b29ce8dd9f0
48+
// Sequelize sets an id attribute by default as primary key, which is not needed in this case
49+
Annotation.removeAttribute('id');
4750
};

lib/models/Annotation.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const { DataTypes } = require('sequelize');
22
const dayjs = require('dayjs');
33

44
exports.attributes = {
5-
ann_id: { type: DataTypes.STRING, primaryKey: true, allowNull: false },
65
user_id: { type: DataTypes.STRING, allowNull: false, defaultValue: '' },
76
item_id: { type: DataTypes.STRING, allowNull: false, defaultValue: '' },
87
item_type: { type: DataTypes.STRING, allowNull: false, defaultValue: '' },

0 commit comments

Comments
 (0)