-
Notifications
You must be signed in to change notification settings - Fork 0
4. MongoDB Database ποΈ
GREAT STAFF uses MongoDB for its flexible schema design. The database is structured into two main instances:
- Development Database:
great-staff-database - Production Database:
great-staff-database-prod
Both databases contain the following collections:
- assignments
- contracts
- demands
- leaves
- projectdemandprofiles
- projects
- projectworkinghours
- skillcategories
- skills
- users
Assignment
{
_id: ObjectId,
userId: [ObjectId], // Array of User IDs
projectDemandProfileId: ObjectId, // Profile ID
createdAt: Date,
updatedAt: Date,
__v: Number
}Required fields: projectDemandProfileId
Contract (for future development)
{
_id: ObjectId,
startDate: Date,
endDate: Date,
weeklyWorkingHours: Number, // between 0 and 40
createdAt: Date,
updatedAt: Date,
__v: Number
}Required fields: startDate, weeklyWorkingHours
Leave (for future development)
{
_id: ObjectId,
startDate: Date,
endDate: Date,
createdAt: Date,
updatedAt: Date,
__v: Number
}Required fields: startDate, endDate
Demand
{
_id: ObjectId,
now: Number,
nextQuarter: Number, // for future development
nextNextQuarter: Number, // for future development
createdAt: Date,
updatedAt: Date,
__v: Number
}Required fields: now
ProjectDemandProfile
{
_id: ObjectId,
name: String,
targetDemandId: ObjectId, // reference to a Demand document
targetSkills: [ObjectId], // Array of Skill IDs
createdAt: Date,
updatedAt: Date,
__v: Number
}Required fields: name, targetDemandId
Project
{
_id: ObjectId,
projectName: String, // max 50 characters
kickoffDate: Date,
deadlineDate: Date,
projectLocation: String, // max 100 characters
demandProfiles: [ObjectId], // Array of ProjectDemandProfile IDs
priority: String, // defined in an Enum
createdAt: Date,
updatedAt: Date,
__v: Number
}Required fields: projectName, kickoffDate
ProjectWorkingHour
{
_id: ObjectId,
date: Date,
numberOfRealWorkingHours: Number,
userId: String, // reference
projectId: String // reference
createdAt: Date,
updatedAt: Date,
__v: Number
}Required fields: date, numberOfRealWorkingHours, userId, projectId
SkillCategory
{
_id: ObjectId, // unique
name: String,
maxPoints: Number,
createdAt: Date,
updatedAt: Date,
__v: Number
}Required fields: name, maxPoints
Skill
{
_id: ObjectId,
skillPoints: Number,
skillCategory: ObjectId, // reference
createdAt: Date,
updatedAt: Date,
__v: Number
}Required fields: skillPoints, skillCategory
User
{
_id: ObjectId,
firstName: String, // max 5 characters
lastName: String, // max 5 characters
email: String, // unique, max 5 characters
password: String, // min 5 characters
canWorkRemote: Boolean, // by default false
leaveIds: [ObjectId], // Array of Leave IDs
skills: [ObjectId], // Array of Skill IDs
officeLocation: String, // defined in an Enum
roles: [String], // defined in an Enum
contractId: ObjectId, // reference
targetSkills: [ObjectId] // Array of Skill IDs
createdAt: Date,
updatedAt: Date,
__v: Number,
}Required fields: firstName, lastName, email, password
GREAT STAFF uses a mix of embedded documents and references to represent relationships:
-
Users to Skills:
- Array of Skill ObjectIds in User document (
skillsandtargetSkillsfields)
- Array of Skill ObjectIds in User document (
-
Projects to ProjectDemandProfiles:
- Array of ProjectDemandProfile ObjectIds in Project document (
demandProfilesfield)
- Array of ProjectDemandProfile ObjectIds in Project document (
-
Assignments:
- References both User (
userIdfield) and ProjectDemandProfile (projectDemandProfileIdfield)
- References both User (
-
Users to Contracts:
- Reference to Contract in User document (
contractIdfield)
- Reference to Contract in User document (
-
ProjectDemandProfiles to Skills:
- Array of Skill ObjectIds in ProjectDemandProfile document (
targetSkillsfield)
- Array of Skill ObjectIds in ProjectDemandProfile document (
GREAT STAFF implements automated daily backups and resets using GitHub Actions.
Key features:
- Daily backup of the production database at 2:00 AM German time (MESZ) // (UTC+2)
- Daily reset of the development database to the state of the production database at 2:00 AM German time (MESZ) // (UTC+2)
The workflow for this process is defined in .github/workflows/daily-db-backup.yml. For more details on the CI/CD process, including this database reset, refer to 5. Deployment, CI/CD & GitHub Actions.
To manually backup or restore:
-
Backup:
mongodump --uri="<MONGO_URL>" --out=<backup_directory> -
Restore:
mongorestore --uri="<MONGO_URL>" <backup_directory>
Replace <MONGO_URL> with the appropriate connection string.
To manually trigger the workflow in GitHub Actions klick "Run workflow" like indicated in the image.

GREAT STAFF uses GitHub Secrets to manage MongoDB configuration securely. These secrets are used in GitHub Actions workflows and deployment processes.
Key MongoDB-related secrets:
-
MONGO_DATABASE: Development database name (great-staff-database) -
MONGO_DATABASE_PROD: Production database name (great-staff-database-prod) -
MONGO_HOST: Development MongoDB host -
MONGO_HOST_PROD: Production MongoDB host -
MONGO_PASSWORD: MongoDB user password -
MONGO_URL: Full connection string for development -
MONGO_URL_PROD: Full connection string for production -
MONGO_USER: MongoDB username
To update these secrets:
- Go to the GitHub repository settings
- Navigate to Secrets and Variables > Actions
- Update the relevant secret values