File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
backend/typescript/prisma Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,16 @@ TypeScript backend and frontend:
138138docker exec -it scv2_ts_backend /bin/bash -c " yarn test"
139139```
140140
141+ ### Seeding the Database
142+ 1 . Make sure your seeding script is named "seed.ts" and under backend/typescript/prisma
143+ 2 . Go into our scv2_ts_backend docker container
144+ 3 . Go to "Files" - ".env"
145+ 4 . Open file editor
146+ 5 . Change the "test" in the database URL to "development" to populate the development collection
147+ 6 . Run the container
148+ 7 . Go to "Exec"
149+ 8 . Type in npx prisma db seed -- --environment development
150+
141151## Updating Documentation
142152
143153To update documentation, checkout the ` gh-pages ` branch:
Original file line number Diff line number Diff line change 1+ import { Prisma , PrismaClient , Status } from "@prisma/client" ;
2+
3+ const prisma = new PrismaClient ( ) ;
4+
5+ async function main ( ) {
6+ const platformSignupPromises : Promise < Prisma . platformSignUpCreateInput > [ ] = [ ] ;
7+
8+ const users = await prisma . user . findMany ( ) ;
9+
10+ // Check if there are users to associate with platform signups
11+ if ( users . length === 0 ) {
12+ throw new Error ( "No users found for seeding platform signups" ) ;
13+ }
14+
15+ const platformSignups : Prisma . platformSignUpCreateInput [ ] = [ ] ;
16+ users . forEach ( ( user ) => {
17+ platformSignups . push ( {
18+ email : user . email ,
19+ firstName : user . firstName ,
20+ lastName : user . lastName ,
21+ status : Status . PENDING ,
22+ } ) ;
23+ } ) ;
24+
25+ platformSignups . forEach ( ( signupRequest ) => {
26+ platformSignupPromises . push (
27+ prisma . platformSignUp . create ( {
28+ data : signupRequest ,
29+ } ) ,
30+ ) ;
31+ } ) ;
32+
33+ await Promise . all ( platformSignupPromises ) ;
34+ }
35+
36+ main ( )
37+ . catch ( ( e ) => console . error ( e ) )
38+ . finally ( async ( ) => {
39+ await prisma . $disconnect ( ) ;
40+ } ) ;
You can’t perform that action at this time.
0 commit comments