diff --git a/migrations/create-events.mjs b/migrations/create-events.mjs new file mode 100644 index 00000000..57f8dc83 --- /dev/null +++ b/migrations/create-events.mjs @@ -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(); +} diff --git a/migrations/create-helpTimers.mjs b/migrations/create-helpTimers.mjs deleted file mode 100644 index ece78a07..00000000 --- a/migrations/create-helpTimers.mjs +++ /dev/null @@ -1,27 +0,0 @@ -export async function up(db) { - await db.createCollection('helpTimers', { - validator: { - $jsonSchema: { - bsonType: 'object', - title: 'Help Timer Object Validation', - required: ['time'], - properties: { - _id: { - bsonType: 'objectId', - description: '_id must be an ObjectId', - }, - time: { - bsonType: 'string', - description: 'time must be a string', - pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}$', - }, - }, - additionalProperties: false, - }, - }, - }); -} - -export async function down(db) { - await db.collection('helpTimers').drop(); -} diff --git a/migrations/create-judgeGroups.mjs b/migrations/create-judgeGroups.mjs deleted file mode 100644 index 38fd58fd..00000000 --- a/migrations/create-judgeGroups.mjs +++ /dev/null @@ -1,34 +0,0 @@ -export async function up(db) { - await db.createCollection('judgeGroups', { - validator: { - $jsonSchema: { - bsonType: 'object', - title: 'JudgeGroup Object Validation', - required: ['type'], - properties: { - _id: { - bsonType: 'objectId', - description: '_id must be an ObjectId', - }, - type: { - enum: ['tech', 'business', 'design'], - description: 'type must be either tech, business, or design.', - }, - judge_ids: { - bsonType: 'array', - description: 'judge_ids must be an array of ObjectIds', - items: { - bsonType: 'objectId', - description: 'judge_id must be an ObjectId', - }, - }, - }, - additionalProperties: false, - }, - }, - }); -} - -export async function down(db) { - await db.collection('judgeGroups').drop(); -} diff --git a/migrations/create-judgeGroupToTeams.mjs b/migrations/create-judgeToTeams.mjs similarity index 68% rename from migrations/create-judgeGroupToTeams.mjs rename to migrations/create-judgeToTeams.mjs index 6bbd0444..1a78db4c 100644 --- a/migrations/create-judgeGroupToTeams.mjs +++ b/migrations/create-judgeToTeams.mjs @@ -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', @@ -31,5 +31,5 @@ export async function up(db) { } export async function down(db) { - await db.collection('judgeGroupToTeams').drop(); + await db.collection('judgeToTeams').drop(); } diff --git a/migrations/create-submissions.mjs b/migrations/create-submissions.mjs index d351e5de..10cec8bc 100644 --- a/migrations/create-submissions.mjs +++ b/migrations/create-submissions.mjs @@ -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: { diff --git a/migrations/create-teams.mjs b/migrations/create-teams.mjs index e2e2d14f..bd782a57 100644 --- a/migrations/create-teams.mjs +++ b/migrations/create-teams.mjs @@ -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: { diff --git a/migrations/create-userToEvents.mjs b/migrations/create-userToEvents.mjs new file mode 100644 index 00000000..0917ed75 --- /dev/null +++ b/migrations/create-userToEvents.mjs @@ -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(); +} diff --git a/migrations/create-judges.mjs b/migrations/create-users.mjs similarity index 72% rename from migrations/create-judges.mjs rename to migrations/create-users.mjs index 84c7e017..888d7bc4 100644 --- a/migrations/create-judges.mjs +++ b/migrations/create-users.mjs @@ -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', @@ -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, @@ -43,5 +43,5 @@ export async function up(db) { } export async function down(db) { - await db.collection('judges').drop(); + await db.collection('users').drop(); }