Skip to content

fix: adds unique index on note and user id of teams table #871

fix: adds unique index on note and user id of teams table

fix: adds unique index on note and user id of teams table #871

Triggered via pull request February 5, 2025 11:00
Status Failure
Total duration 2m 56s
Artifacts 1
This run and associated checks have been archived and are scheduled for deletion. Learn more about checks retention

run-tests.yml

on: pull_request
Matrix: tests
report-coverage
0s
report-coverage
Fit to window
Zoom out
Zoom in

Annotations

2 errors
src/presentation/http/router/noteSettings.test.ts > NoteSettings API > PATCH /note-settings/:notePublicId/team > Returns status code 404 and "User does not belong to Note's team" message if no such a note exists: 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
tests (285-fix-join-route-user-duplication)
Process completed with exit code 1.

Artifacts

Produced during runtime
Name Size Digest
coverage-main Expired
99.8 KB
sha256:e8d38ed490ee269db15612e35bef71fd56f12e34c552f14f2f9e04c7256f66a5