Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
fix: migrations passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
elribonazo committed Dec 23, 2023
1 parent dbcab63 commit 6aeec41
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
11 changes: 11 additions & 0 deletions packages/database/coverage/coverage-summary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{"total": {"lines":{"total":223,"covered":223,"skipped":0,"pct":100},"statements":{"total":234,"covered":234,"skipped":0,"pct":100},"functions":{"total":80,"covered":80,"skipped":0,"pct":100},"branches":{"total":76,"covered":76,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/database/src/index.ts": {"lines":{"total":169,"covered":169,"skipped":0,"pct":100},"functions":{"total":70,"covered":70,"skipped":0,"pct":100},"statements":{"total":180,"covered":180,"skipped":0,"pct":100},"branches":{"total":54,"covered":54,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/database/src/schemas/Credential.ts": {"lines":{"total":11,"covered":11,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":11,"covered":11,"skipped":0,"pct":100},"branches":{"total":4,"covered":4,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/database/src/schemas/CredentialRequestMetadata.ts": {"lines":{"total":3,"covered":3,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":3,"covered":3,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/database/src/schemas/DID.ts": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":1,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/database/src/schemas/DIDPair.ts": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":1,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/database/src/schemas/LinkSecret.ts": {"lines":{"total":3,"covered":3,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":3,"covered":3,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/database/src/schemas/Mediator.ts": {"lines":{"total":4,"covered":4,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":4,"covered":4,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/database/src/schemas/Message.ts": {"lines":{"total":3,"covered":3,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":3,"covered":3,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/database/src/schemas/PrivateKey.ts": {"lines":{"total":28,"covered":28,"skipped":0,"pct":100},"functions":{"total":5,"covered":5,"skipped":0,"pct":100},"statements":{"total":28,"covered":28,"skipped":0,"pct":100},"branches":{"total":18,"covered":18,"skipped":0,"pct":100}}
}
2 changes: 0 additions & 2 deletions packages/database/tests/pluto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,6 @@ describe("Pluto encrypted testing with different storages", () => {
return this.secreto;
},
},
autoMigrate: false,
schema: {
version: 1,
primaryKey: "name",
Expand Down Expand Up @@ -915,7 +914,6 @@ describe("Pluto encrypted testing with different storages", () => {
return this.secreto;
},
},
autoMigrate: false,
schema: {
version: 2,
primaryKey: "test",
Expand Down
19 changes: 5 additions & 14 deletions packages/encryption/src/migration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import {
shareReplay,
switchMap
} from 'rxjs/operators';
import {
Subject,

} from 'rxjs';
import { INTERNAL_CONTEXT_COLLECTION, InternalStoreCollectionDocType, NumberFunctionMap, PROMISE_RESOLVE_NULL, RxDocumentData, RxJsonSchema, RxSchema, RxStorageInstance, RxStorageInstanceCreationParams, WithAttachmentsData, clone, createRevision, createRxSchema, deepEqual, flatClone, getDefaultRxDocumentMeta, getPreviousVersions, getPrimaryKeyOfInternalDocument, getWrappedStorageInstance, newRxError, normalizeMangoQuery, now, overwritable, runAsyncPluginHooks, runPluginHooks, toPromise } from 'rxdb';

import { MigrationState, RxStorage } from 'rxdb';
Expand Down Expand Up @@ -215,7 +211,7 @@ export function runStrategyIfNotNull(
}
}

export function getBatchOfOldCollection(
export async function getBatchOfOldCollection(
oldCollection: OldRxCollection,
batchSize: number,
notMatching: any[]
Expand All @@ -234,17 +230,12 @@ export function getBatchOfOldCollection(
selector: query,
sort: [{ [oldCollection.schema.primaryPath]: 'asc' } as any],
limit: batchSize,
skip: 0
skip: notMatching.length
}
);
return storageInstance
.query(preparedQuery)
.then(result => result.documents
.map(doc => {
doc = flatClone(doc);
return doc;
})
);
const results = await storageInstance.query(preparedQuery);
const documents = results.documents.map((doc) => flatClone(doc))
return documents;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/indexdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ const database = db = await Database.createEncrypted(
## QA & Documentation
| Statements | Branches | Functions | Lines |
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
| ![Statements](https://img.shields.io/badge/statements-76%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-63.9%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-76.47%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-76.65%25-red.svg?style=flat) |
| ![Statements](https://img.shields.io/badge/statements-76.17%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-64.12%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-76.47%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-76.84%25-red.svg?style=flat) |
4 changes: 2 additions & 2 deletions packages/indexdb/coverage/coverage-summary.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{"total": {"lines":{"total":287,"covered":220,"skipped":0,"pct":76.65},"statements":{"total":300,"covered":228,"skipped":0,"pct":76},"functions":{"total":68,"covered":52,"skipped":0,"pct":76.47},"branches":{"total":133,"covered":85,"skipped":0,"pct":63.9},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
{"total": {"lines":{"total":285,"covered":219,"skipped":0,"pct":76.84},"statements":{"total":298,"covered":227,"skipped":0,"pct":76.17},"functions":{"total":68,"covered":52,"skipped":0,"pct":76.47},"branches":{"total":131,"covered":84,"skipped":0,"pct":64.12},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/indexdb/src/index.ts": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":1,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/indexdb/src/storage-dexie/dexie-helper.ts": {"lines":{"total":95,"covered":86,"skipped":0,"pct":90.52},"functions":{"total":22,"covered":21,"skipped":0,"pct":95.45},"statements":{"total":100,"covered":90,"skipped":0,"pct":90},"branches":{"total":48,"covered":39,"skipped":0,"pct":81.25}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/indexdb/src/storage-dexie/dexie-query.ts": {"lines":{"total":66,"covered":29,"skipped":0,"pct":43.93},"functions":{"total":13,"covered":4,"skipped":0,"pct":30.76},"statements":{"total":70,"covered":31,"skipped":0,"pct":44.28},"branches":{"total":32,"covered":10,"skipped":0,"pct":31.25}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/indexdb/src/storage-dexie/rx-storage-dexie.ts": {"lines":{"total":12,"covered":11,"skipped":0,"pct":91.66},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"statements":{"total":12,"covered":11,"skipped":0,"pct":91.66},"branches":{"total":5,"covered":4,"skipped":0,"pct":80}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/indexdb/src/storage-dexie/rx-storage-dexie.ts": {"lines":{"total":10,"covered":10,"skipped":0,"pct":100},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"statements":{"total":10,"covered":10,"skipped":0,"pct":100},"branches":{"total":3,"covered":3,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/indexdb/src/storage-dexie/rx-storage-instance-dexie.ts": {"lines":{"total":113,"covered":93,"skipped":0,"pct":82.3},"functions":{"total":30,"covered":24,"skipped":0,"pct":80},"statements":{"total":117,"covered":95,"skipped":0,"pct":81.19},"branches":{"total":48,"covered":32,"skipped":0,"pct":66.66}}
}
3 changes: 0 additions & 3 deletions packages/indexdb/src/storage-dexie/rx-storage-dexie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ export class RxStorageDexie implements RxStorage<DexieStorageInternals, DexieSet
ensureNoBooleanIndex(params.schema);

const instance = await createDexieStorageInstance(this, params, this.settings);
if (instance.closed) {
debugger;
}
return instance
}
}
Expand Down

0 comments on commit 6aeec41

Please sign in to comment.