[Frontend] - Add scripts for mock data initialization and database wiping - #439
Merged
thomasdejaeghere merged 4 commits intoApr 23, 2025
Conversation
5 tasks
rvdkeere
marked this pull request as ready for review
April 16, 2025 13:55
rvdkeere
requested review from
Adrien-VL,
LambrechtMaarten,
bramcomyn,
brentjan,
brieromb,
lennertdr and
thomasdejaeghere
April 19, 2025 11:22
lennertdr
reviewed
Apr 21, 2025
lennertdr
left a comment
Contributor
There was a problem hiding this comment.
Maybe walk us through in the meeting this evening
rvdkeere
marked this pull request as draft
April 21, 2025 17:45
…ata-initialization-and-database-wiping
added name to assignments
rvdkeere
marked this pull request as ready for review
April 22, 2025 17:40
lennertdr
reviewed
Apr 24, 2025
| @@ -0,0 +1,275 @@ | |||
| /** | |||
| * 🌱 Seed function: Random Database Seeder | |||
bramcomyn
deleted the
410-frontend---add-scripts-for-mock-data-initialization-and-database-wiping
branch
May 10, 2025 08:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds new scripts for putting random mock data in the database, and for wiping the database tables clean. These scripts can be run manually, but the functions called by them are exported separately and can be used for other testing purposes as well. They are located in backend/extra.
The clear script truncates all tables and can be manually run with:
docker-compose exec backend npm run db:clearThe seed script clears the db first and then fills it with new data. It can be manually run with:
docker-compose exec backend npm run db:seedThe current implementation of seedDatabase uses faker-js to generate random data in fields like names and descriptions.
Feedback on this mechanism is welcome, for example if you want some accounts or classes with fixed names, let me know and I will add them separately. The benefit of using faker here is that you have a more flexible amount of entities, since you can easily edit the seed file to include however many entities you want of each type.
Emails are handled differently: they use a fixed format of {
nr}.{student/teacher}.ugent.be wherenris any number from 1 to 5 for teachers and from 1 to 20 for students.For every account, the password is "asdf1234" to make it easy to log in during demos or manual testing.