@@ -11,7 +11,7 @@ import {
1111async function seed ( ) {
1212 try {
1313 // ---------------- Insert Dummy Users ----------------
14- const insertedUsers = await db . insert ( users ) . values ( [
14+ await db . insert ( users ) . values ( [
1515 { uid : "student1" , userRole : "student" } ,
1616 { uid : "student2" , userRole : "student" } ,
1717 { uid : "student3" , userRole : "student" } ,
@@ -22,47 +22,54 @@ async function seed() {
2222 const insertedCategories = await db
2323 . insert ( categories )
2424 . values ( [
25- { category : "Project Type" } , // id will be returned
25+ { category : "Project Type" } ,
2626 { category : "Department" } ,
2727 { category : "Programming Language" } ,
28+ { category : "Year of Submission" } ,
29+ { category : "Domain" } ,
2830 ] )
2931 . returning ( { id : categories . categoryId , name : categories . category } ) ;
30- console . log ( "✅ Categories inserted" , insertedCategories ) ;
32+ console . log ( "✅ Categories inserted" ) ;
3133
32- // ---------------- Insert Category Option Values ----------------
33- // Use dynamic IDs from insertedCategories
34- const projectTypeId = insertedCategories . find ( c => c . name === "Project Type" ) ! . id ;
35- const departmentId = insertedCategories . find ( c => c . name === "Department" ) ! . id ;
36- const languageId = insertedCategories . find ( c => c . name === "Programming Language" ) ! . id ;
34+ // Map category names to IDs
35+ const catId = ( name : string ) => insertedCategories . find ( c => c . name === name ) ! . id ;
3736
37+ // ---------------- Insert Category Option Values ----------------
3838 const insertedOptions = await db
3939 . insert ( categoryOptionValues )
4040 . values ( [
4141 // Project Type
42- { optionName : "Web Development" , categoryId : projectTypeId } ,
43- { optionName : "Android Development" , categoryId : projectTypeId } ,
44- { optionName : "IoT" , categoryId : projectTypeId } ,
45- { optionName : "AI/ML" , categoryId : projectTypeId } ,
42+ { optionName : "Web Development" , categoryId : catId ( "Project Type" ) } ,
43+ { optionName : "Android Development" , categoryId : catId ( "Project Type" ) } ,
44+ { optionName : "IoT" , categoryId : catId ( "Project Type" ) } ,
45+ { optionName : "AI/ML" , categoryId : catId ( "Project Type" ) } ,
4646
4747 // Departments
48- { optionName : "CSE" , categoryId : departmentId } ,
49- { optionName : "ECE" , categoryId : departmentId } ,
50- { optionName : "MECH" , categoryId : departmentId } ,
51- { optionName : "CIVIL" , categoryId : departmentId } ,
52- { optionName : "IT" , categoryId : departmentId } ,
53- { optionName : "EEE" , categoryId : departmentId } ,
48+ { optionName : "CSE" , categoryId : catId ( "Department" ) } ,
49+ { optionName : "ECE" , categoryId : catId ( "Department" ) } ,
50+ { optionName : "MECH" , categoryId : catId ( "Department" ) } ,
51+ { optionName : "CIVIL" , categoryId : catId ( "Department" ) } ,
52+ { optionName : "IT" , categoryId : catId ( "Department" ) } ,
53+ { optionName : "EEE" , categoryId : catId ( "Department" ) } ,
5454
5555 // Programming Languages
56- { optionName : "Python" , categoryId : languageId } ,
57- { optionName : "Java" , categoryId : languageId } ,
58- { optionName : "C++" , categoryId : languageId } ,
59- { optionName : "JavaScript" , categoryId : languageId } ,
60- { optionName : "Kotlin" , categoryId : languageId } ,
56+ { optionName : "Python" , categoryId : catId ( "Programming Language" ) } ,
57+ { optionName : "Java" , categoryId : catId ( "Programming Language" ) } ,
58+ { optionName : "C++" , categoryId : catId ( "Programming Language" ) } ,
59+ { optionName : "JavaScript" , categoryId : catId ( "Programming Language" ) } ,
60+ { optionName : "Kotlin" , categoryId : catId ( "Programming Language" ) } ,
61+
62+ // Year of Submission
63+ { optionName : "2025" , categoryId : catId ( "Year of Submission" ) } ,
64+
65+ // Domain
66+ { optionName : "Education" , categoryId : catId ( "Domain" ) } ,
67+ { optionName : "Agriculture" , categoryId : catId ( "Domain" ) } ,
68+ { optionName : "Campus" , categoryId : catId ( "Domain" ) } ,
6169 ] )
6270 . returning ( { id : categoryOptionValues . optionId , name : categoryOptionValues . optionName } ) ;
63- console . log ( "✅ Category option values inserted" , insertedOptions ) ;
71+ console . log ( "✅ Category option values inserted" ) ;
6472
65- // Helper to get option ID by name
6673 const getOptionId = ( name : string ) => insertedOptions . find ( o => o . name === name ) ! . id ;
6774
6875 // ---------------- Insert Projects ----------------
@@ -104,24 +111,30 @@ async function seed() {
104111 } ,
105112 ] )
106113 . returning ( { id : projects . projectId , name : projects . projectName } ) ;
107- console . log ( "✅ Projects inserted successfully" , insertedProjects ) ;
114+ console . log ( "✅ Projects inserted" ) ;
108115
109116 // ---------------- Link Projects with Options ----------------
110117 const projectOptionData = [
111118 // AI Chatbot
112- { projectId : insertedProjects [ 0 ] . id , categoryId : projectTypeId , optionId : getOptionId ( "AI/ML" ) } ,
113- { projectId : insertedProjects [ 0 ] . id , categoryId : departmentId , optionId : getOptionId ( "CSE" ) } ,
114- { projectId : insertedProjects [ 0 ] . id , categoryId : languageId , optionId : getOptionId ( "Python" ) } ,
119+ { projectId : insertedProjects [ 0 ] . id , categoryId : catId ( "Project Type" ) , optionId : getOptionId ( "AI/ML" ) } ,
120+ { projectId : insertedProjects [ 0 ] . id , categoryId : catId ( "Department" ) , optionId : getOptionId ( "CSE" ) } ,
121+ { projectId : insertedProjects [ 0 ] . id , categoryId : catId ( "Programming Language" ) , optionId : getOptionId ( "Python" ) } ,
122+ { projectId : insertedProjects [ 0 ] . id , categoryId : catId ( "Year of Submission" ) , optionId : getOptionId ( "2025" ) } ,
123+ { projectId : insertedProjects [ 0 ] . id , categoryId : catId ( "Domain" ) , optionId : getOptionId ( "Education" ) } ,
115124
116125 // Smart Irrigation
117- { projectId : insertedProjects [ 1 ] . id , categoryId : projectTypeId , optionId : getOptionId ( "IoT" ) } ,
118- { projectId : insertedProjects [ 1 ] . id , categoryId : departmentId , optionId : getOptionId ( "MECH" ) } ,
119- { projectId : insertedProjects [ 1 ] . id , categoryId : languageId , optionId : getOptionId ( "Java" ) } ,
126+ { projectId : insertedProjects [ 1 ] . id , categoryId : catId ( "Project Type" ) , optionId : getOptionId ( "IoT" ) } ,
127+ { projectId : insertedProjects [ 1 ] . id , categoryId : catId ( "Department" ) , optionId : getOptionId ( "MECH" ) } ,
128+ { projectId : insertedProjects [ 1 ] . id , categoryId : catId ( "Programming Language" ) , optionId : getOptionId ( "Java" ) } ,
129+ { projectId : insertedProjects [ 1 ] . id , categoryId : catId ( "Year of Submission" ) , optionId : getOptionId ( "2025" ) } ,
130+ { projectId : insertedProjects [ 1 ] . id , categoryId : catId ( "Domain" ) , optionId : getOptionId ( "Agriculture" ) } ,
120131
121132 // Campus Navigation
122- { projectId : insertedProjects [ 2 ] . id , categoryId : projectTypeId , optionId : getOptionId ( "Android Development" ) } ,
123- { projectId : insertedProjects [ 2 ] . id , categoryId : departmentId , optionId : getOptionId ( "CSE" ) } ,
124- { projectId : insertedProjects [ 2 ] . id , categoryId : languageId , optionId : getOptionId ( "Kotlin" ) } ,
133+ { projectId : insertedProjects [ 2 ] . id , categoryId : catId ( "Project Type" ) , optionId : getOptionId ( "Android Development" ) } ,
134+ { projectId : insertedProjects [ 2 ] . id , categoryId : catId ( "Department" ) , optionId : getOptionId ( "CSE" ) } ,
135+ { projectId : insertedProjects [ 2 ] . id , categoryId : catId ( "Programming Language" ) , optionId : getOptionId ( "Kotlin" ) } ,
136+ { projectId : insertedProjects [ 2 ] . id , categoryId : catId ( "Year of Submission" ) , optionId : getOptionId ( "2025" ) } ,
137+ { projectId : insertedProjects [ 2 ] . id , categoryId : catId ( "Domain" ) , optionId : getOptionId ( "Campus" ) } ,
125138 ] ;
126139
127140 await db . insert ( projectOptions ) . values ( projectOptionData ) ;
0 commit comments