@mikro-orm/better-sqlite 6.1.13-dev.18 → 6.1.13-dev.19

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.
@@ -1,10 +1,12 @@
1
1
  import type { Connection, Dictionary } from '@mikro-orm/core';
2
- import { SchemaHelper, type AbstractSqlConnection, type IndexDef, type CheckDef } from '@mikro-orm/knex';
2
+ import { SchemaHelper, type AbstractSqlConnection, type IndexDef, type CheckDef, type Column } from '@mikro-orm/knex';
3
3
  export declare class BetterSqliteSchemaHelper extends SchemaHelper {
4
4
  disableForeignKeysSQL(): string;
5
5
  enableForeignKeysSQL(): string;
6
6
  supportsSchemaConstraints(): boolean;
7
7
  getListTablesSQL(): string;
8
+ getDropDatabaseSQL(name: string): string;
9
+ getDropColumnsSQL(tableName: string, columns: Column[], schemaName?: string): string;
8
10
  private parseTableDefinition;
9
11
  getColumns(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<any[]>;
10
12
  getEnumDefinitions(connection: AbstractSqlConnection, checks: CheckDef[], tableName: string, schemaName: string): Promise<Dictionary<string[]>>;
@@ -16,6 +16,18 @@ class BetterSqliteSchemaHelper extends knex_1.SchemaHelper {
16
16
  return `select name as table_name from sqlite_master where type = 'table' and name != 'sqlite_sequence' and name != 'geometry_columns' and name != 'spatial_ref_sys' `
17
17
  + `union all select name as table_name from sqlite_temp_master where type = 'table' order by name`;
18
18
  }
19
+ getDropDatabaseSQL(name) {
20
+ if (name === ':memory:') {
21
+ return '';
22
+ }
23
+ return `drop database if exists ${this.platform.quoteIdentifier(name)}`;
24
+ }
25
+ getDropColumnsSQL(tableName, columns, schemaName) {
26
+ const name = this.platform.quoteIdentifier((schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName);
27
+ return columns.map(column => {
28
+ return `alter table ${name} drop column ${this.platform.quoteIdentifier(column.name)}`;
29
+ }).join(';\n');
30
+ }
19
31
  parseTableDefinition(sql, cols) {
20
32
  const columns = {};
21
33
  // extract all columns definitions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/better-sqlite",
3
- "version": "6.1.13-dev.18",
3
+ "version": "6.1.13-dev.19",
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.1.13-dev.18",
61
+ "@mikro-orm/knex": "6.1.13-dev.19",
62
62
  "better-sqlite3": "9.4.4",
63
63
  "fs-extra": "11.2.0",
64
64
  "sqlstring-sqlite": "0.1.1"
@@ -67,6 +67,6 @@
67
67
  "@mikro-orm/core": "^6.1.12"
68
68
  },
69
69
  "peerDependencies": {
70
- "@mikro-orm/core": "6.1.13-dev.18"
70
+ "@mikro-orm/core": "6.1.13-dev.19"
71
71
  }
72
72
  }