MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / getSnapshotPath

Method getSnapshotPath

packages/migrations/src/Migrator.ts:59–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57 }
58
59 private async getSnapshotPath(): Promise<string> {
60 if (!this.#snapshotPath) {
61 const { fs } = await import('@mikro-orm/core/fs-utils');
62 // for snapshots, we always want to use the path based on `emit` option, regardless of whether we run in TS context
63 /* v8 ignore next */
64 const snapshotPath = this.options.emit === 'ts' && this.options.pathTs ? this.options.pathTs : this.options.path!;
65 const absoluteSnapshotPath = fs.absolutePath(snapshotPath, this.config.get('baseDir'));
66 const dbName = this.config.get('dbName')!.replace(/\\/g, '/').split('/').pop()!.replace(/:/g, '');
67 const snapshotName = this.options.snapshotName ?? `.snapshot-${dbName}`;
68 this.#snapshotPath = fs.normalizePath(absoluteSnapshotPath, `${snapshotName}.json`);
69 }
70
71 return this.#snapshotPath;
72 }
73
74 protected override async init(): Promise<void> {
75 if (this.initialized) {

Callers 3

hasSnapshotMethod · 0.95
getSchemaFromSnapshotMethod · 0.95
storeCurrentSchemaMethod · 0.95

Calls 3

absolutePathMethod · 0.80
normalizePathMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected