Skip to content

Commit

Permalink
Merge pull request #139 from HackDavis/feat/schema-restructure
Browse files Browse the repository at this point in the history
modified migrations to reflect new schema
  • Loading branch information
brandonw504 authored Oct 23, 2024
2 parents 958f52b + 2d6b88c commit 9dd97dc
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 79 deletions.
42 changes: 42 additions & 0 deletions migrations/create-events.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export async function up(db) {
await db.createCollection('events', {
validator: {
$jsonSchema: {
bsonType: 'object',
title: 'Events Object Validation',
required: ['name', 'type', 'location', 'time'],
properties: {
_id: {
bsonType: 'objectId',
description: '_id must be an ObjectId',
},
name: {
bsonType: 'string',
description: 'name must be a string',
},
type: {
enum: ['workshop', 'meal', 'mixer'],
description: 'type must be a valid event type',
},
description: {
bsonType: 'string',
description: 'description must be a string',
},
location: {
bsonType: 'string',
description: 'location must be a string',
},
time: {
bsonType: 'date',
description: 'time must be a date',
},
},
additionalProperties: false,
},
},
});
}

export async function down(db) {
await db.collection('events').drop();
}
27 changes: 0 additions & 27 deletions migrations/create-helpTimers.mjs

This file was deleted.

34 changes: 0 additions & 34 deletions migrations/create-judgeGroups.mjs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
export async function up(db) {
await db.createCollection('judgeGroupToTeams', {
await db.createCollection('judgeToTeams', {
validator: {
$jsonSchema: {
bsonType: 'object',
title: 'JudgeGroupToTeam Object Validation',
required: ['judge_group_id', 'team_id', 'round'],
title: 'JudgeToTeams Object Validation',
required: ['judge_id', 'team_id', 'round'],
properties: {
_id: {
bsonType: 'objectId',
description: '_id must be an ObjectId',
},
judge_group_id: {
judge_id: {
bsonType: 'objectId',
description: 'judge_group_id must be an ObjectId',
description: 'judge_id must be an ObjectId',
},
team_id: {
bsonType: 'objectId',
Expand All @@ -31,5 +31,5 @@ export async function up(db) {
}

export async function down(db) {
await db.collection('judgeGroupToTeams').drop();
await db.collection('judgeToTeams').drop();
}
2 changes: 1 addition & 1 deletion migrations/create-submissions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function up(db) {
validator: {
$jsonSchema: {
bsonType: 'object',
title: 'Submission Object Validation',
title: 'Submissions Object Validation',
required: ['judge_id', 'team_id'],
properties: {
_id: {
Expand Down
2 changes: 1 addition & 1 deletion migrations/create-teams.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function up(db) {
validator: {
$jsonSchema: {
bsonType: 'object',
title: 'Team Object Validation',
title: 'Teams Object Validation',
required: ['number', 'name', 'tracks'],
properties: {
_id: {
Expand Down
30 changes: 30 additions & 0 deletions migrations/create-userToEvents.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export async function up(db) {
await db.createCollection('userToEvents', {
validator: {
$jsonSchema: {
bsonType: 'object',
title: 'userToEvents Object Validation',
required: ['user_id', 'event_id'],
properties: {
_id: {
bsonType: 'objectId',
description: '_id must be an ObjectId',
},
user_id: {
bsonType: 'objectId',
description: 'user_id must be an ObjectId',
},
event_id: {
bsonType: 'objectId',
description: 'event_id must be an ObjectId',
},
},
additionalProperties: false,
},
},
});
}

export async function down(db) {
await db.collection('userToEvents').drop();
}
20 changes: 10 additions & 10 deletions migrations/create-judges.mjs → migrations/create-users.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export async function up(db) {
await db.createCollection('judges', {
await db.createCollection('users', {
validator: {
$jsonSchema: {
bsonType: 'object',
title: 'Judge Object Validation',
required: ['name', 'email', 'password', 'specialty', 'role'],
title: 'Users Object Validation',
required: ['name', 'email', 'password', 'team_id', 'specialty', 'role'],
properties: {
_id: {
bsonType: 'objectId',
Expand All @@ -23,17 +23,17 @@ export async function up(db) {
bsonType: 'string',
description: 'encrypted password must be a string',
},
team_id: {
bsonType: 'objectId',
description: 'team_id must be an ObjectId',
},
specialty: {
enum: ['tech', 'business', 'design'],
description: 'specialty must be either tech, business, or design',
},
judge_group_id: {
bsonType: 'objectId',
description: 'judge_group_id must be an ObjectId',
},
role: {
enum: ['judge', 'admin'],
description: 'role must be either judge or admin',
enum: ['hacker', 'judge', 'admin'],
description: 'role must be either hacker, judge, or admin',
},
},
additionalProperties: false,
Expand All @@ -43,5 +43,5 @@ export async function up(db) {
}

export async function down(db) {
await db.collection('judges').drop();
await db.collection('users').drop();
}

0 comments on commit 9dd97dc

Please sign in to comment.