@mikro-orm/knex 6.0.0-dev.316 → 6.0.0-dev.317

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.0.0-dev.316",
3
+ "version": "6.0.0-dev.317",
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",
@@ -66,6 +66,6 @@
66
66
  "@mikro-orm/core": "^5.0.0"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.0.0-dev.316"
69
+ "@mikro-orm/core": "6.0.0-dev.317"
70
70
  }
71
71
  }
@@ -1,4 +1,4 @@
1
- import { AbstractSchemaGenerator, type MikroORM, type ISchemaGenerator } from '@mikro-orm/core';
1
+ import { AbstractSchemaGenerator, type MikroORM, type ISchemaGenerator, type ClearDatabaseOptions, type CreateSchemaOptions, type EnsureDatabaseOptions, type DropSchemaOptions, type UpdateSchemaOptions } from '@mikro-orm/core';
2
2
  import type { SchemaDifference } from '../typings';
3
3
  import { DatabaseSchema } from './DatabaseSchema';
4
4
  import type { AbstractSqlDriver } from '../AbstractSqlDriver';
@@ -7,56 +7,20 @@ export declare class SqlSchemaGenerator extends AbstractSchemaGenerator<Abstract
7
7
  private readonly options;
8
8
  protected lastEnsuredDatabase?: string;
9
9
  static register(orm: MikroORM): void;
10
- createSchema(options?: {
11
- wrap?: boolean;
12
- schema?: string;
13
- }): Promise<void>;
10
+ createSchema(options?: CreateSchemaOptions): Promise<void>;
14
11
  /**
15
12
  * Returns true if the database was created.
16
13
  */
17
- ensureDatabase(): Promise<boolean>;
14
+ ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
18
15
  getTargetSchema(schema?: string): DatabaseSchema;
19
- getCreateSchemaSQL(options?: {
20
- wrap?: boolean;
21
- schema?: string;
22
- }): Promise<string>;
23
- dropSchema(options?: {
24
- wrap?: boolean;
25
- dropMigrationsTable?: boolean;
26
- dropDb?: boolean;
27
- schema?: string;
28
- }): Promise<void>;
29
- clearDatabase(options?: {
30
- schema?: string;
31
- truncate?: boolean;
32
- }): Promise<void>;
33
- getDropSchemaSQL(options?: {
34
- wrap?: boolean;
35
- dropMigrationsTable?: boolean;
36
- schema?: string;
37
- }): Promise<string>;
16
+ getCreateSchemaSQL(options?: CreateSchemaOptions): Promise<string>;
17
+ dropSchema(options?: DropSchemaOptions): Promise<void>;
18
+ clearDatabase(options?: ClearDatabaseOptions): Promise<void>;
19
+ getDropSchemaSQL(options?: Omit<DropSchemaOptions, 'dropDb'>): Promise<string>;
38
20
  private getSchemaName;
39
- updateSchema(options?: {
40
- wrap?: boolean;
41
- safe?: boolean;
42
- dropTables?: boolean;
43
- fromSchema?: DatabaseSchema;
44
- schema?: string;
45
- }): Promise<void>;
46
- getUpdateSchemaSQL(options?: {
47
- wrap?: boolean;
48
- safe?: boolean;
49
- dropTables?: boolean;
50
- fromSchema?: DatabaseSchema;
51
- schema?: string;
52
- }): Promise<string>;
53
- getUpdateSchemaMigrationSQL(options?: {
54
- wrap?: boolean;
55
- safe?: boolean;
56
- dropTables?: boolean;
57
- fromSchema?: DatabaseSchema;
58
- schema?: string;
59
- }): Promise<{
21
+ updateSchema(options?: UpdateSchemaOptions<DatabaseSchema>): Promise<void>;
22
+ getUpdateSchemaSQL(options?: UpdateSchemaOptions<DatabaseSchema>): Promise<string>;
23
+ getUpdateSchemaMigrationSQL(options?: UpdateSchemaOptions<DatabaseSchema>): Promise<{
60
24
  up: string;
61
25
  down: string;
62
26
  }>;
@@ -19,7 +19,7 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
19
19
  /**
20
20
  * Returns true if the database was created.
21
21
  */
22
- async ensureDatabase() {
22
+ async ensureDatabase(options) {
23
23
  const dbName = this.config.get('dbName');
24
24
  if (this.lastEnsuredDatabase === dbName) {
25
25
  return true;
@@ -32,8 +32,14 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
32
32
  await this.createDatabase(dbName);
33
33
  this.config.set('dbName', dbName);
34
34
  await this.driver.reconnect();
35
+ if (options?.create) {
36
+ await this.createSchema(options);
37
+ }
35
38
  return true;
36
39
  }
40
+ if (options?.clear) {
41
+ await this.clearDatabase(options);
42
+ }
37
43
  return false;
38
44
  }
39
45
  getTargetSchema(schema) {