From 6941c0707e67c4af30ddf513d33e4a5c82a12e5e Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Thu, 21 Apr 2022 18:35:22 +0100 Subject: [PATCH] feat: add schema for migrations --- server/src/external/mongo/schemas.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/src/external/mongo/schemas.ts b/server/src/external/mongo/schemas.ts index 1cf4ce981..4ec378d81 100644 --- a/server/src/external/mongo/schemas.ts +++ b/server/src/external/mongo/schemas.ts @@ -725,4 +725,18 @@ export const DatabaseSchemas: Record< playtype: isValidPlaytype, milestones: ["string"], }), + migrations: prSchemaify({ + migrationID: "string", + status: p.isIn("applied", "pending"), + appliedOn: (self, parent) => { + if (parent.status === "pending") { + return ( + self === undefined || + `Expected appliedOn to be undefined since status was pending.` + ); + } + + return p.isPositiveInteger(self); + }, + }), };