Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corps-directory
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fhurtado14
corps-directory
Merge requests
!6
Populate involvement type and involvement lookup in database
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Populate involvement type and involvement lookup in database
Populate-Involvement-Table
into
main
Overview
0
Commits
1
Pipelines
0
Changes
2
Merged
kainguyen
requested to merge
Populate-Involvement-Table
into
main
5 months ago
Overview
0
Commits
1
Pipelines
0
Changes
2
Expand
Populate involvement type and involvement lookup in database
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
ff83fae6
1 commit,
5 months ago
2 files
+
237
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
backend/config/database/databaseInitializer.js
+
104
−
0
Options
@@ -6,6 +6,12 @@ const {
addStateIfNotExists
,
checkTableExistence
,
}
=
require
(
"
../../repository/stateRepository
"
);
const
{
addInvolvementTypeIfNotExists
,
addInvolvementIfNotExists
,
checkInvolvementTypeTableExistence
,
checkInvolvementLookupTableExistence
,
}
=
require
(
"
../../repository/involvementRepository
"
);
/*
Class responsible for populating the database
@@ -133,11 +139,109 @@ class DatabaseInitializer {
}
}
/*
Creates all the involvement types
*/
async
initializeInvolvementTypes
()
{
await
checkInvolvementTypeTableExistence
();
// Ensure the table exists
const
involvementTypes
=
[
"
Asian American Cadet Organization
"
,
"
Black Cadet Organization
"
,
"
Cadet Alumni Team
"
,
"
Cadet Language Organization
"
,
"
Cadets for a Cause
"
,
"
Coast Guard Auxiliary
"
,
"
Color Guard
"
,
"
Conrad Cavalry
"
,
"
Corps Marksmanship Team
"
,
"
Eagle Scout Association
"
,
"
EMT Staff
"
,
"
Esprit de Corps
"
,
"
Executive Committee
"
,
"
Fenix (Latin Cadets)
"
,
"
Gregory Guard
"
,
"
Growley Team
"
,
"
Hall Council
"
,
"
Helping Educate Regarding Orientation (HERO)
"
,
"
Historian Staff
"
,
"
Honor Court
"
,
"
Inspector General Staff
"
,
"
Men's Basketball
"
,
"
O-Course Committee
"
,
"
Ordinance Staff
"
,
"
Rappelling Tower Committee
"
,
"
Recruiting Staff
"
,
"
Sash and Saber Honor Society
"
,
"
Signal Corps
"
,
"
Skipper Crew
"
,
"
Society of American Military Engineers
"
,
"
VPI Battalion
"
,
"
VTCC Cyber Team
"
,
"
Women's Basketball
"
,
];
for
(
const
type
of
involvementTypes
)
{
await
addInvolvementTypeIfNotExists
(
type
);
// Add each involvement type
}
}
/*
Creates all the involvement lookups directly based on the defined involvement types
*/
async
initializeInvolvementLookups
()
{
await
checkInvolvementLookupTableExistence
();
// Ensure the lookup table exists
// Define lookup entries with type IDs (these IDs should correspond to your actual involvement type IDs)
const
involvementLookups
=
[
{
involvementTypeId
:
1
},
// Asian American Cadet Organization
{
involvementTypeId
:
2
},
// Black Cadet Organization
{
involvementTypeId
:
3
},
// Cadet Alumni Team
{
involvementTypeId
:
4
},
// Cadet Language Organization
{
involvementTypeId
:
5
},
// Cadets for a Cause
{
involvementTypeId
:
6
},
// Coast Guard Auxiliary
{
involvementTypeId
:
7
},
// Color Guard
{
involvementTypeId
:
8
},
// Conrad Cavalry
{
involvementTypeId
:
9
},
// Corps Marksmanship Team
{
involvementTypeId
:
10
},
// Eagle Scout Association
{
involvementTypeId
:
11
},
// EMT Staff
{
involvementTypeId
:
12
},
// Esprit de Corps
{
involvementTypeId
:
13
},
// Executive Committee
{
involvementTypeId
:
14
},
// Fenix (Latin Cadets)
{
involvementTypeId
:
15
},
// Gregory Guard
{
involvementTypeId
:
16
},
// Growley Team
{
involvementTypeId
:
17
},
// Hall Council
{
involvementTypeId
:
18
},
// Helping Educate Regarding Orientation (HERO)
{
involvementTypeId
:
19
},
// Historian Staff
{
involvementTypeId
:
20
},
// Honor Court
{
involvementTypeId
:
21
},
// Inspector General Staff
{
involvementTypeId
:
22
},
// Men’s Basketball
{
involvementTypeId
:
23
},
// O-Course Committee
{
involvementTypeId
:
24
},
// Ordinance Staff
{
involvementTypeId
:
25
},
// Rappelling Tower Committee
{
involvementTypeId
:
26
},
// Recruiting Staff
{
involvementTypeId
:
27
},
// Sash and Saber Honor Society
{
involvementTypeId
:
28
},
// Signal Corps
{
involvementTypeId
:
29
},
// Skipper Crew
{
involvementTypeId
:
30
},
// Society of American Military Engineers
{
involvementTypeId
:
31
},
// VPI Battalion
{
involvementTypeId
:
32
},
// VTCC Cyber Team
{
involvementTypeId
:
33
},
// Women’s Basketball
];
for
(
const
entry
of
involvementLookups
)
{
await
addInvolvementIfNotExists
(
entry
.
involvementTypeId
);
// Add entry to involvementLookup
}
}
async
initializeAll
()
{
await
this
.
testDBConnection
();
await
this
.
initializeRoles
();
await
this
.
initializeTestUsers
();
await
this
.
initializeStates
();
await
this
.
initializeInvolvementTypes
();
await
this
.
initializeInvolvementLookups
();
console
.
log
(
"
database init completed.
"
);
}
Loading