Skip to content

Commit

Permalink
feat(migrations): allow configuring snapshot name
Browse files Browse the repository at this point in the history
Closes #3562
  • Loading branch information
B4nan committed Oct 9, 2022
1 parent ea3f6fd commit 4bbe355
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/core/src/utils/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ export type MigrationsOptions = {
dropTables?: boolean;
safe?: boolean;
snapshot?: boolean;
snapshotName?: string;
emit?: 'js' | 'ts';
generator?: Constructor<IMigrationGenerator>;
fileName?: (timestamp: string) => string;
Expand Down
3 changes: 2 additions & 1 deletion packages/migrations/src/Migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export class Migrator implements IMigrator {
const snapshotPath = this.options.emit === 'ts' && this.options.pathTs ? this.options.pathTs : this.options.path!;
const absoluteSnapshotPath = Utils.absolutePath(snapshotPath, this.config.get('baseDir'));
const dbName = basename(this.config.get('dbName'));
this.snapshotPath = Utils.normalizePath(absoluteSnapshotPath, `.snapshot-${dbName}.json`);
const snapshotName = this.options.snapshotName ?? `.snapshot-${dbName}`;
this.snapshotPath = Utils.normalizePath(absoluteSnapshotPath, `${snapshotName}.json`);
this.createUmzug();
}

Expand Down

0 comments on commit 4bbe355

Please sign in to comment.