Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicare data created by prisma seed #708

Closed
John-Paul-Larkin opened this issue Feb 3, 2024 · 6 comments
Closed

Duplicare data created by prisma seed #708

John-Paul-Larkin opened this issue Feb 3, 2024 · 6 comments

Comments

@John-Paul-Larkin
Copy link
Member

There is a difference between how Niall and Remos code create the random data in the seed file. When generating the user data, prisma takes care of auto assigning an id. When generating the communities data, an id is assigned in the function.

The chance package is invoked with argument 1, which results in a repeatable source of random generation. Therefore, when creating a new community array, the ids are unique, but the actual data is repeated. This results in duplicated data(with unique ids)

Basically, each time we run ‘prisma db seed’ the community, membership and event data is increased, which exponentially increases the RSVP data.

@John-Paul-Larkin
Copy link
Member Author

Further to this. If run repeatedly, the prisma seed will eventually fail, because the relationship and event data models combine ids to create a foreign key. The ids are duplicated, so the seed will fail when it hits a certain combination.

@NiallJoeMaher
Copy link
Contributor

Should we add a command to delete the data first in the seed file to ensure these duplicates don't happen?

@NiallJoeMaher
Copy link
Contributor

Duplicate of #677 just as an FYI! But thanks for tackling this

@John-Paul-Larkin
Copy link
Member Author

Should we add a command to delete the data first in the seed file to ensure these duplicates don't happen?

My thought process was that we could run the seed without wiping the data that was created since the previous seed.
ie Any created test articles would remain in the db, and only the seed data would be updated.

That is probably overthinking it, so I will implement your suggestion.

@NiallJoeMaher
Copy link
Contributor

I think we should because if we change the schema you could end up with things out of sync. But I also wonder can we somehow warn the user that they are about to blow their data so it's not a fun surprise 😂 Let's merge what you currently have for now anyway.

@John-Paul-Larkin
Copy link
Member Author

Yes, that makes sense. I will look into in later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants