fix: adds unique index on note and user id of teams table #871
Annotations
2 errors
Run tests:
src/tests/utils/database-helpers.ts#L248
SequelizeUniqueConstraintError: Validation error
❯ Query.run node_modules/sequelize/src/dialects/postgres/query.js:76:25
❯ node_modules/sequelize/src/sequelize.js:650:28
❯ DatabaseHelpers.insertNoteTeam src/tests/utils/database-helpers.ts:248:5
❯ src/presentation/http/router/noteSettings.test.ts:765:7
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { errors: [ { message: 'note_id must be unique', type: 'unique violation', path: 'note_id', value: '1', origin: 'DB', instance: null, validatorKey: 'not_unique', validatorName: null, validatorArgs: [], constructor: 'Function<ValidationErrorItem>', isValidationErrorItemOrigin: 'Function<isValidationErrorItemOrigin>', normalizeString: 'Function<normalizeString>', getValidatorKey: 'Function<getValidatorKey>' }, { message: 'user_id must be unique', type: 'unique violation', path: 'user_id', value: '1', origin: 'DB', instance: null, validatorKey: 'not_unique', validatorName: null, validatorArgs: [], constructor: 'Function<ValidationErrorItem>', isValidationErrorItemOrigin: 'Function<isValidationErrorItemOrigin>', normalizeString: 'Function<normalizeString>', getValidatorKey: 'Function<getValidatorKey>' } ], parent: { stack: 'error: duplicate key value violates unique constraint "note_teams_note_id_user_id"\n at Parser.parseErrorMessage (/home/runner/work/notes.api/notes.api/node_modules/pg-protocol/src/parser.ts:369:69)\n at Parser.handlePacket (/home/runner/work/notes.api/notes.api/node_modules/pg-protocol/src/parser.ts:188:21)\n at Parser.parse (/home/runner/work/notes.api/notes.api/node_modules/pg-protocol/src/parser.ts:103:30)\n at Socket.<anonymous> (/home/runner/work/notes.api/notes.api/node_modules/pg-protocol/src/index.ts:7:48)\n at Socket.emit (node:events:518:28)\n at addChunk (node:internal/streams/readable:561:12)\n at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)\n at Socket.Readable.push (node:internal/streams/readable:392:5)\n at TCP.onStreamRead (node:internal/stream_base_commons:191:23)', message: 'duplicate key value violates unique constraint "note_teams_note_id_user_id"', length: 234, name: 'error', severity: 'ERROR', code: '23505', detail: 'Key (note_id, user_id)=(1, 1) already exists.', hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: 'public', table: 'note_teams', column: undefined, dataType: undefined, constraint: 'note_teams_note_id_user_id', file: 'nbtinsert.c', line: '649', routine: '_bt_check_unique', sql: 'INSERT INTO public.note_teams ("user_id", "note_id", "role") VALUES (1, 1, 1)', parameters: undefined, constructor: 'Function<DatabaseError>', toString: 'Function<toString>' }, original: { stack: 'error: duplicate key value violates unique constraint "note_teams_note_id_user_id"\n at Parser.parseErrorMessage (/home/runner/work/notes.api/notes.api/node_modules/pg-protocol/src/parser.ts:369:69)\n at Parser.handlePacket (/home/runner/work/notes.api/notes.api/node_modules/pg-protocol/src/parser.ts:188:21)\n at Parser.parse (/home/runner/work/notes.api/notes.api/node_modules/pg-protocol/src/parser.ts:103:30)\n at Socket.<anonymous> (/home/runner/work/notes.api/notes.api/node_modules/pg-protocol/src/index.ts:7:48)\n at Socket.emit (node:events:518:28)\n at addChunk (node:internal/streams/readable:561:12)\n at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)\n at Socket.Readable.push (node:internal/streams/readable:392:5)\n at TCP.onStreamRead (node:internal/stream_base_commons:191:23)', message: 'duplicate key value violates unique constraint "note_teams_note_id_user_id"', length: 234, name: 'error', severity: 'ERROR', code: '23505', detail: 'Key (note_id, user_id)=(1, 1) already exists.', hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: 'public', table: 'note_teams', column: undefined, dataType: undefined, constraint: 'note_teams_note_id_user_id', file: 'nbtinsert.c', line: '649', routine: '_bt_check_unique', sql: 'INSE
|
Run tests
Process completed with exit code 1.
|
Loading