Open
Description
Observed
Creating a Donation record in the database via Sequelize fails with the following error:
ERROR: duplicate key value violates unique constraint <"xxx_pkey">
DETAIL: Key (id)=(15) already exists.
Cause
Turns out this only happens when there is already data in the DB that was put there via the seed script (npm run db:seed
). This comment suggests that including the primary key attribute in the seed data is unadvisable.
Solution
The seed data needs to be updated to remove the IDs from Donations and Donors. However, the seeded Donation records still should have a donorId
that corresponds to a Donor primary key. So
- Donors need to be inserted first;
- We need some way to get the list of Donor IDs and randomly (?) assign them to the Donations to be seeded.
In the interim, the DB should be reset and the seed script not used. The /donations/upload
endpoint can be used to insert data.
Metadata
Metadata
Assignees
Labels
No labels