@mikro-orm/migrations 6.2.10-dev.91 → 6.2.10-dev.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Migrator.d.ts CHANGED
@@ -26,7 +26,7 @@ export declare class Migrator implements IMigrator {
26
26
  /**
27
27
  * @inheritDoc
28
28
  */
29
- createInitialMigration(path?: string, name?: string): Promise<MigrationResult>;
29
+ createInitialMigration(path?: string, name?: string, blank?: boolean): Promise<MigrationResult>;
30
30
  private createUmzug;
31
31
  /**
32
32
  * Initial migration can be created only if:
package/Migrator.js CHANGED
@@ -48,7 +48,7 @@ class Migrator {
48
48
  */
49
49
  async createMigration(path, blank = false, initial = false, name) {
50
50
  if (initial) {
51
- return this.createInitialMigration(path, name);
51
+ return this.createInitialMigration(path, name, blank);
52
52
  }
53
53
  await this.ensureMigrationsDirExists();
54
54
  const diff = await this.getSchemaDiff(blank, initial);
@@ -71,13 +71,13 @@ class Migrator {
71
71
  /**
72
72
  * @inheritDoc
73
73
  */
74
- async createInitialMigration(path, name) {
74
+ async createInitialMigration(path, name, blank = false) {
75
75
  await this.ensureMigrationsDirExists();
76
- const schemaExists = await this.validateInitialMigration();
77
- const diff = await this.getSchemaDiff(false, true);
76
+ const schemaExists = await this.validateInitialMigration(blank);
77
+ const diff = await this.getSchemaDiff(blank, true);
78
78
  const migration = await this.generator.generate(diff, path, name);
79
79
  await this.storeCurrentSchema();
80
- if (schemaExists) {
80
+ if (schemaExists && !blank) {
81
81
  await this.storage.logMigration({ name: migration[1], context: null });
82
82
  }
83
83
  return {
@@ -126,7 +126,7 @@ class Migrator {
126
126
  * If existing schema contains all of the tables already, we return true, based on that we mark the migration as already executed.
127
127
  * If only some of the tables are present, exception is thrown.
128
128
  */
129
- async validateInitialMigration() {
129
+ async validateInitialMigration(blank) {
130
130
  const executed = await this.getExecutedMigrations();
131
131
  const pending = await this.getPendingMigrations();
132
132
  if (executed.length > 0 || pending.length > 0) {
@@ -148,7 +148,7 @@ class Migrator {
148
148
  exists.add(table.schema ? `${table.schema}.${table.name}` : table.name);
149
149
  }
150
150
  });
151
- if (expected.size === 0) {
151
+ if (expected.size === 0 && !blank) {
152
152
  throw new Error('No entities found');
153
153
  }
154
154
  if (exists.size > 0 && expected.size !== exists.size) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/migrations",
3
- "version": "6.2.10-dev.91",
3
+ "version": "6.2.10-dev.93",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -58,7 +58,7 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@mikro-orm/knex": "6.2.10-dev.91",
61
+ "@mikro-orm/knex": "6.2.10-dev.93",
62
62
  "fs-extra": "11.2.0",
63
63
  "umzug": "3.8.1"
64
64
  },
@@ -66,6 +66,6 @@
66
66
  "@mikro-orm/core": "^6.2.9"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.2.10-dev.91"
69
+ "@mikro-orm/core": "6.2.10-dev.93"
70
70
  }
71
71
  }