Skip to content

Bug - test seeding DB fails #2727

@TestYouTestUntilTest

Description

@TestYouTestUntilTest

Description

pnpm run kyb-manual-review-example results in failure.

Seeding database...
PrismaClientKnownRequestError:
Invalid prisma.alert.createMany() invocation:
Foreign key constraint failed on the field: Alert_businessId_fkey (index)
at Rn.handleRequestError (/home/XXXXXXX/ballerine/node_modules/.pnpm/@prisma[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:174:7325)
at Rn.handleAndLogRequestError (/home/XXXXXXX/ballerine/node_modules/.pnpm/@prisma[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:174:6754)
at Rn.request (/home/XXXXXXX/ballerine/node_modules/.pnpm/@prisma[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:174:6344)
at async Promise.all (index 16)
at async seedTransactionsAlerts (/home/XXXXXXX/ballerine/services/workflows-service/scripts/alerts/generate-alerts.ts:2:21212)
at async seed (/home/XXXXXXX/ballerine/services/workflows-service/scripts/seed.ts:2:20323) {
code: 'P2003',
clientVersion: '4.16.2',
meta: { field_name: 'Alert_businessId_fkey (index)' }
}

Expected Behaviour

BackOffice, Collection and Workflows services should start listening

Actual Behaviour

Command Fails

Environment

  • Node 19.x:

Steps to Reproduce

pnpm run kyb-manual-review-example would exit the process with the database updating error

Possible solution

Alert_businessId
So this businessId is not existed at the time of adding that alert!!!!!!

../scripts/seed.ts

  await seedTransactionsAlerts(client, {
    project: project1,
    //businessIds: businessRiskIds,//!!!!!!!!WRONG
    businessIds: businessIds,////CORRECT
    counterpartyIds: ids1
      .map(
        ({ counterpartyOriginatorId, counterpartyBeneficiaryId }) =>
          counterpartyOriginatorId || counterpartyBeneficiaryId,
      )
      .filter(Boolean) as string[],
    agentUserIds: agentUsers.map(({ id }) => id),
  });

businessRiskIds has another ids – they are not existed!!!!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions