Skip to content

Commit

Permalink
fix(migrations): generate snapshot too when using --initial
Browse files Browse the repository at this point in the history
Closes #2800
  • Loading branch information
B4nan committed Feb 20, 2022
1 parent b39b6ad commit 4857be7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/docs/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ accessed via `Migration.getKnex()`;

## Initial migration

> This is optional and only needed for the specific use case, when both entities and schema already exist.
If we want to start using migrations, and we already have the schema generated,
we can do so by creating so called initial migration:

Expand Down
2 changes: 2 additions & 0 deletions docs/versioned_docs/version-5.0/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ accessed via `Migration.getKnex()`;

## Initial migration

> This is optional and only needed for the specific use case, when both entities and schema already exist.
If we want to start using migrations, and we already have the schema generated,
we can do so by creating so called initial migration:

Expand Down
1 change: 1 addition & 0 deletions packages/migrations/src/Migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class Migrator implements IMigrator {
await this.ensureMigrationsDirExists();
const schemaExists = await this.validateInitialMigration();
const diff = await this.getSchemaDiff(false, true);
await this.storeCurrentSchema();
const migration = await this.generator.generate(diff, path);

if (schemaExists) {
Expand Down

0 comments on commit 4857be7

Please sign in to comment.