Skip to content

Commit

Permalink
fix: upgrade mongoose
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `mongoose` is now required as peer dependency in minimal version `5.11.12`
  • Loading branch information
hellivan committed Jan 20, 2021
1 parent e4b00d5 commit 53ca892
Show file tree
Hide file tree
Showing 9 changed files with 1,300 additions and 1,156 deletions.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"cleanup-lockfile": "yarn-deduplicate --strategy fewer"
},
"dependencies": {
"@types/mongodb": "^3.0.0",
"@types/mongoose": "^5.0.0"
"@types/mongodb": "^3.0.0"
},
"husky": {
"hooks": {
Expand All @@ -65,6 +64,7 @@
"jest-circus": "^26.6.3",
"jest-html-reporter": "^3.3.0",
"jest-junit": "^12.0.0",
"mongoose": "5.11.12",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"rimraf": "^3.0.2",
Expand All @@ -74,7 +74,6 @@
"yarn-deduplicate": "^3.1.0"
},
"peerDependencies": {
"mongodb": "^3.0.0",
"mongoose": "^5.0.0"
"mongoose": "^5.11.12"
}
}
4 changes: 2 additions & 2 deletions src/abstract-migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export abstract class AbstractMigrator {
return this.versionStorage.writeVersion(version);
}

protected abstract async upgrade(fromVersion: number | null, toVersion: number): Promise<void>;
protected abstract upgrade(fromVersion: number | null, toVersion: number): Promise<void>;

protected abstract async downgrade(fromVersion: number, toVersion: number): Promise<void>;
protected abstract downgrade(fromVersion: number, toVersion: number): Promise<void>;
}
2 changes: 1 addition & 1 deletion src/mongodb-collection-migrator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Collection, Db } from 'mongodb';
import type { Collection, Db } from 'mongodb';

import { AbstractMigrator } from './abstract-migrator';
import { MongodbCollectionVersionStorage } from './mongodb-collection-version-storage';
Expand Down
4 changes: 2 additions & 2 deletions src/mongodb-collection-version-storage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Collection } from 'mongodb';
import type { Collection } from 'mongodb';

import { VersionStorage, VersionInformation } from './abstract-migrator';
import type { VersionStorage, VersionInformation } from './abstract-migrator';

export class MongodbCollectionVersionStorage implements VersionStorage {
constructor(private readonly versionCollection: Collection<VersionInformation>) {}
Expand Down
7 changes: 4 additions & 3 deletions src/mongodb-collection-versioning-utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Db } from 'mongodb';
import type { Db } from 'mongodb';

import { VersionInformation } from './abstract-migrator';
import { CollectionMigrationHandler, CollectionMigrator } from './mongodb-collection-migrator';
import type { VersionInformation } from './abstract-migrator';
import type { CollectionMigrationHandler } from './mongodb-collection-migrator';
import { CollectionMigrator } from './mongodb-collection-migrator';
import { MongodbCollectionVersionStorage } from './mongodb-collection-version-storage';
import { getGlobalMongooseConnectionDb } from './utils';

Expand Down
4 changes: 2 additions & 2 deletions src/mongoose-model-migrator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Document, Model } from 'mongoose';
import { Db } from 'mongodb';
import type { Document, Model } from 'mongoose';
import type { Db } from 'mongodb';

import { AbstractMigrator } from './abstract-migrator';
import { MongodbCollectionVersionStorage } from './mongodb-collection-version-storage';
Expand Down
9 changes: 5 additions & 4 deletions src/mongoose-model-versioning-utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Document, Model } from 'mongoose';
import { Db } from 'mongodb';
import type { Document, Model } from 'mongoose';
import type { Db } from 'mongodb';

import { ModelMigrationHandler, ModelMigrator } from './mongoose-model-migrator';
import type { ModelMigrationHandler } from './mongoose-model-migrator';
import { ModelMigrator } from './mongoose-model-migrator';
import { getGlobalMongooseConnectionDb } from './utils';
import { VersionInformation } from './abstract-migrator';
import type { VersionInformation } from './abstract-migrator';
import { MongodbCollectionVersionStorage } from './mongodb-collection-version-storage';

export interface ModelMigratorOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Db } from 'mongodb';
import type { Db } from 'mongodb';

export async function getGlobalMongooseConnectionDb(): Promise<Db> {
const mongoose = await import('mongoose');
Expand Down
2,417 changes: 1,280 additions & 1,137 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 53ca892

Please sign in to comment.