Skip to content

Commit

Permalink
Merge branch 'feature/migrations' into chore/active-playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Feb 10, 2021
2 parents 4c3acc1 + c44f416 commit 9512382
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/plugins/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ const migrationSchema = new Schema({
/**
* Custom MongoDBStorage based on Mongoose and with timestamps.
*/
class MongoDBStorage {
const mongooseStorage = {
async logMigration({ name, context: uw }) {
const { Migration } = uw.models;

await Migration.create({
migrationName: name,
});
}
},

async unlogMigration({ name, context: uw }) {
const { Migration } = uw.models;

await Migration.deleteOne({
migrationName: name,
});
}
},

async executed({ context: uw }) {
const { Migration } = uw.models;
Expand All @@ -46,8 +46,8 @@ class MongoDBStorage {
.select({ migrationName: 1 })
.lean();
return documents.map((doc) => doc.migrationName);
}
}
},
};

async function migrationsPlugin(uw) {
const redLock = new RedLock([uw.redis]);
Expand All @@ -57,7 +57,7 @@ async function migrationsPlugin(uw) {
const migrator = new Umzug({
migrations,
context: uw,
storage: new MongoDBStorage(),
storage: mongooseStorage,
logger: {
// Only `info` is used right now. When Umzug actually implements the warn/error
// levels we could pass in different logging functions.
Expand Down

0 comments on commit 9512382

Please sign in to comment.