Skip to content

Commit

Permalink
feat: automigration
Browse files Browse the repository at this point in the history
  • Loading branch information
zkrising committed Apr 9, 2024
1 parent 1f7bd38 commit d96fef0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/src/lib/migration/migrations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import UserFollowersMigration from "./migrations/add-following-to-users";
import AddLockedAt from "./migrations/add-lockedat";
import UGPTAddPreferredRanking from "./migrations/add-preferredRanking-to-ugpt";
import UGPTRivalsMigration from "./migrations/add-rivals-to-ugpt";
import FixUndefinedBMSData from "./migrations/fix-undefined-bms-data";
Expand Down Expand Up @@ -50,6 +51,7 @@ const REGISTERED_MIGRATIONS: Array<Migration> =
SessionsToScoreIDs,
V3PropsMigration,
V3ScoresMigration,
AddLockedAt,
];

// only apply type-specific migrations if we're not in testing
Expand Down
30 changes: 30 additions & 0 deletions server/src/lib/migration/migrations/add-lockedat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import db from "external/mongo/db";
import type { Migration } from "utils/types";

const migration: Migration = {
id: "add-lockedat",
up: async () => {
await db["import-locks"].update(
{},
{
$set: {
lockedAt: null,
},
},
{ multi: true }
);
},
down: async () => {
await db["import-locks"].update(
{},
{
$unset: {
lockedAt: 1,
},
},
{ multi: true }
);
},
};

export default migration;

0 comments on commit d96fef0

Please sign in to comment.