@@ -3,11 +3,12 @@ import { PrismaClient } from '@prisma/client';
33const prisma = new PrismaClient ( ) ;
44
55async function main ( ) {
6- console . log ( '🌱 Seeding DevCard database...' ) ;
6+ console . log ( 'Seeding database.... ...' ) ;
77
8- // Create test user
9- const testUser = await prisma . user . upsert ( {
10- where : { username : 'devcard-demo' } ,
8+ const user = await prisma . user . upsert ( {
9+ where : {
10+ username : 'devcard-demo' ,
11+ } ,
1112 update : { } ,
1213 create : {
1314 email : 'demo@devcard.dev' ,
@@ -17,83 +18,103 @@ async function main() {
1718 pronouns : 'they/them' ,
1819 role : 'Senior Software Engineer' ,
1920 company : 'OpenSource Inc.' ,
20- avatarUrl : null ,
2121 accentColor : '#6366f1' ,
22- provider : 'github' ,
23- providerId : 'demo-12345' ,
22+ isActive : true ,
23+ emailVerified : true ,
24+
25+ identities : {
26+ create : {
27+ provider : 'github' ,
28+ providerId : 'demo-12345' ,
29+ } ,
30+ } ,
2431 } ,
2532 } ) ;
2633
27- console . log ( ` ✅ Created user: ${ testUser . displayName } (@${ testUser . username } )` ) ;
34+ console . log ( `User created: ${ user . username } ` ) ;
35+
36+ await prisma . cardLink . deleteMany ( { } ) ;
37+ await prisma . card . deleteMany ( { } ) ;
38+ await prisma . platformLink . deleteMany ( {
39+ where : {
40+ userId : user . id ,
41+ } ,
42+ } ) ;
2843
29- // Create platform links
3044 const links = await Promise . all ( [
3145 prisma . platformLink . create ( {
3246 data : {
33- userId : testUser . id ,
47+ userId : user . id ,
3448 platform : 'github' ,
3549 username : 'alexchen' ,
3650 url : 'https://github.com/alexchen' ,
3751 displayOrder : 0 ,
3852 } ,
3953 } ) ,
54+
4055 prisma . platformLink . create ( {
4156 data : {
42- userId : testUser . id ,
57+ userId : user . id ,
4358 platform : 'linkedin' ,
4459 username : 'alexchen-dev' ,
45- url : 'https://www. linkedin.com/in/alexchen-dev' ,
60+ url : 'https://linkedin.com/in/alexchen-dev' ,
4661 displayOrder : 1 ,
4762 } ,
4863 } ) ,
64+
4965 prisma . platformLink . create ( {
5066 data : {
51- userId : testUser . id ,
67+ userId : user . id ,
5268 platform : 'twitter' ,
5369 username : 'alexchendev' ,
5470 url : 'https://x.com/alexchendev' ,
5571 displayOrder : 2 ,
5672 } ,
5773 } ) ,
74+
5875 prisma . platformLink . create ( {
5976 data : {
60- userId : testUser . id ,
61- platform : 'devfolio ' ,
62- username : 'alexchen' ,
63- url : 'https://devfolio.co/@ alexchen' ,
77+ userId : user . id ,
78+ platform : 'portfolio ' ,
79+ username : 'alexchen.dev ' ,
80+ url : 'https://alexchen.dev ' ,
6481 displayOrder : 3 ,
6582 } ,
6683 } ) ,
84+
6785 prisma . platformLink . create ( {
6886 data : {
69- userId : testUser . id ,
70- platform : 'portfolio ' ,
71- username : 'https:// alexchen.dev ' ,
72- url : 'https://alexchen.dev ' ,
87+ userId : user . id ,
88+ platform : 'devfolio ' ,
89+ username : 'alexchen' ,
90+ url : 'https://devfolio.co/@alexchen ' ,
7391 displayOrder : 4 ,
7492 } ,
7593 } ) ,
94+
7695 prisma . platformLink . create ( {
7796 data : {
78- userId : testUser . id ,
97+ userId : user . id ,
7998 platform : 'leetcode' ,
8099 username : 'alexchen' ,
81100 url : 'https://leetcode.com/u/alexchen' ,
82101 displayOrder : 5 ,
83102 } ,
84103 } ) ,
104+
85105 prisma . platformLink . create ( {
86106 data : {
87- userId : testUser . id ,
107+ userId : user . id ,
88108 platform : 'discord' ,
89109 username : 'alexchen#4242' ,
90110 url : '' ,
91111 displayOrder : 6 ,
92112 } ,
93113 } ) ,
114+
94115 prisma . platformLink . create ( {
95116 data : {
96- userId : testUser . id ,
117+ userId : user . id ,
97118 platform : 'email' ,
98119 username : 'alex@devcard.dev' ,
99120 url : 'mailto:alex@devcard.dev' ,
@@ -102,50 +123,77 @@ async function main() {
102123 } ) ,
103124 ] ) ;
104125
105- console . log ( ` ✅ Created ${ links . length } platform links` ) ;
126+ console . log ( `${ links . length } platform links created ` ) ;
106127
107- // Create context cards
108128 const professionalCard = await prisma . card . create ( {
109129 data : {
110- userId : testUser . id ,
130+ userId : user . id ,
111131 title : 'Professional' ,
112132 isDefault : true ,
133+
113134 cardLinks : {
114135 create : [
115- { platformLinkId : links [ 0 ] . id , displayOrder : 0 } , // GitHub
116- { platformLinkId : links [ 1 ] . id , displayOrder : 1 } , // LinkedIn
117- { platformLinkId : links [ 2 ] . id , displayOrder : 2 } , // Twitter
118- { platformLinkId : links [ 4 ] . id , displayOrder : 3 } , // Portfolio
136+ {
137+ platformLinkId : links [ 0 ] . id ,
138+ displayOrder : 0 ,
139+ } ,
140+ {
141+ platformLinkId : links [ 1 ] . id ,
142+ displayOrder : 1 ,
143+ } ,
144+ {
145+ platformLinkId : links [ 2 ] . id ,
146+ displayOrder : 2 ,
147+ } ,
148+ {
149+ platformLinkId : links [ 3 ] . id ,
150+ displayOrder : 3 ,
151+ } ,
119152 ] ,
120153 } ,
121154 } ,
122155 } ) ;
123156
124157 const hackathonCard = await prisma . card . create ( {
125158 data : {
126- userId : testUser . id ,
159+ userId : user . id ,
127160 title : 'Hackathon' ,
128- isDefault : false ,
161+
129162 cardLinks : {
130163 create : [
131- { platformLinkId : links [ 0 ] . id , displayOrder : 0 } , // GitHub
132- { platformLinkId : links [ 3 ] . id , displayOrder : 1 } , // Devfolio
133- { platformLinkId : links [ 6 ] . id , displayOrder : 2 } , // Discord
134- { platformLinkId : links [ 2 ] . id , displayOrder : 3 } , // Twitter
164+ {
165+ platformLinkId : links [ 0 ] . id ,
166+ displayOrder : 0 ,
167+ } ,
168+ {
169+ platformLinkId : links [ 4 ] . id ,
170+ displayOrder : 1 ,
171+ } ,
172+ {
173+ platformLinkId : links [ 6 ] . id ,
174+ displayOrder : 2 ,
175+ } ,
176+ {
177+ platformLinkId : links [ 2 ] . id ,
178+ displayOrder : 3 ,
179+ } ,
135180 ] ,
136181 } ,
137182 } ,
138183 } ) ;
139184
140- console . log ( ` ✅ Created cards: "${ professionalCard . title } ", "${ hackathonCard . title } "` ) ;
141- console . log ( '\n🎉 Seed complete! Try: GET /api/u/devcard-demo' ) ;
185+ console . log (
186+ `Cards created: ${ professionalCard . title } , ${ hackathonCard . title } ` ,
187+ ) ;
188+
189+ console . log ( '\nSeed complete' ) ;
142190}
143191
144192main ( )
145- . catch ( ( error ) => {
146- console . error ( '❌ Seed failed: ' , error ) ;
147- process . exit ( 1 ) ;
193+ . catch ( ( err ) => {
194+ console . error ( 'Seed failed' , err ) ;
195+ return ;
148196 } )
149197 . finally ( async ( ) => {
150198 await prisma . $disconnect ( ) ;
151- } ) ;
199+ } ) ;
0 commit comments