@mikro-orm/postgresql 7.0.0-dev.33 → 7.0.0-dev.331
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/PostgreSqlConnection.d.ts +1 -1
- package/PostgreSqlConnection.js +3 -1
- package/PostgreSqlDriver.d.ts +8 -2
- package/PostgreSqlDriver.js +13 -1
- package/PostgreSqlEntityManager.d.ts +18 -0
- package/PostgreSqlEntityManager.js +23 -0
- package/PostgreSqlMikroORM.d.ts +7 -8
- package/PostgreSqlMikroORM.js +6 -8
- package/PostgreSqlPlatform.d.ts +2 -102
- package/PostgreSqlPlatform.js +10 -353
- package/README.md +7 -4
- package/index.d.ts +4 -5
- package/index.js +3 -4
- package/package.json +35 -35
- package/raw.d.ts +67 -0
- package/raw.js +64 -0
- package/PostgreSqlExceptionConverter.d.ts +0 -8
- package/PostgreSqlExceptionConverter.js +0 -48
- package/PostgreSqlSchemaHelper.d.ts +0 -56
- package/PostgreSqlSchemaHelper.js +0 -546
- package/types/FullTextType.d.ts +0 -14
- package/types/FullTextType.js +0 -59
- package/types/index.d.ts +0 -1
- package/types/index.js +0 -1
package/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
<a href="https://mikro-orm.io"><img src="https://raw.githubusercontent.com/mikro-orm/mikro-orm/master/docs/static/img/logo-readme.svg?sanitize=true" alt="MikroORM" /></a>
|
|
3
3
|
</h1>
|
|
4
4
|
|
|
5
|
-
TypeScript ORM for Node.js based on Data Mapper, [Unit of Work](https://mikro-orm.io/docs/unit-of-work/) and [Identity Map](https://mikro-orm.io/docs/identity-map/) patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL
|
|
5
|
+
TypeScript ORM for Node.js based on Data Mapper, [Unit of Work](https://mikro-orm.io/docs/unit-of-work/) and [Identity Map](https://mikro-orm.io/docs/identity-map/) patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL, SQLite (including libSQL), MSSQL and Oracle databases.
|
|
6
6
|
|
|
7
7
|
> Heavily inspired by [Doctrine](https://www.doctrine-project.org/) and [Hibernate](https://hibernate.org/).
|
|
8
8
|
|
|
9
|
-
[](https://
|
|
10
|
-
[](https://
|
|
9
|
+
[](https://npmx.dev/package/@mikro-orm/core)
|
|
10
|
+
[](https://npmx.dev/package/@mikro-orm/core)
|
|
11
11
|
[](https://discord.gg/w8bjxFHS7X)
|
|
12
|
-
[](https://
|
|
12
|
+
[](https://npmx.dev/package/@mikro-orm/core)
|
|
13
13
|
[](https://coveralls.io/r/mikro-orm/mikro-orm?branch=master)
|
|
14
14
|
[](https://github.com/mikro-orm/mikro-orm/actions?workflow=tests)
|
|
15
15
|
|
|
@@ -181,6 +181,7 @@ yarn add @mikro-orm/core @mikro-orm/mysql # for mysql/mariadb
|
|
|
181
181
|
yarn add @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
|
|
182
182
|
yarn add @mikro-orm/core @mikro-orm/postgresql # for postgresql
|
|
183
183
|
yarn add @mikro-orm/core @mikro-orm/mssql # for mssql
|
|
184
|
+
yarn add @mikro-orm/core @mikro-orm/oracledb # for oracle
|
|
184
185
|
yarn add @mikro-orm/core @mikro-orm/sqlite # for sqlite
|
|
185
186
|
yarn add @mikro-orm/core @mikro-orm/libsql # for libsql
|
|
186
187
|
```
|
|
@@ -381,6 +382,8 @@ See also the list of contributors who [participated](https://github.com/mikro-or
|
|
|
381
382
|
|
|
382
383
|
Please ⭐️ this repository if this project helped you!
|
|
383
384
|
|
|
385
|
+
> If you'd like to support my open-source work, consider sponsoring me directly at [github.com/sponsors/b4nan](https://github.com/sponsors/b4nan).
|
|
386
|
+
|
|
384
387
|
## 📝 License
|
|
385
388
|
|
|
386
389
|
Copyright © 2018 [Martin Adámek](https://github.com/b4nan).
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export * from '@mikro-orm/
|
|
1
|
+
export * from '@mikro-orm/sql';
|
|
2
2
|
export * from './PostgreSqlConnection.js';
|
|
3
3
|
export * from './PostgreSqlDriver.js';
|
|
4
4
|
export * from './PostgreSqlPlatform.js';
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export { PostgreSqlMikroORM as MikroORM, PostgreSqlOptions as Options, definePostgreSqlConfig as defineConfig, } from './PostgreSqlMikroORM.js';
|
|
5
|
+
export { PostgreSqlEntityManager as EntityManager } from './PostgreSqlEntityManager.js';
|
|
6
|
+
export { PostgreSqlMikroORM as MikroORM, type PostgreSqlOptions as Options, definePostgreSqlConfig as defineConfig, } from './PostgreSqlMikroORM.js';
|
|
7
|
+
export { raw } from './raw.js';
|
package/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export * from '@mikro-orm/
|
|
1
|
+
export * from '@mikro-orm/sql';
|
|
2
2
|
export * from './PostgreSqlConnection.js';
|
|
3
3
|
export * from './PostgreSqlDriver.js';
|
|
4
4
|
export * from './PostgreSqlPlatform.js';
|
|
5
|
-
export
|
|
6
|
-
export * from './PostgreSqlExceptionConverter.js';
|
|
7
|
-
export * from './types/index.js';
|
|
5
|
+
export { PostgreSqlEntityManager as EntityManager } from './PostgreSqlEntityManager.js';
|
|
8
6
|
export { PostgreSqlMikroORM as MikroORM, definePostgreSqlConfig as defineConfig, } from './PostgreSqlMikroORM.js';
|
|
7
|
+
export { raw } from './raw.js';
|
package/package.json
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/postgresql",
|
|
3
|
-
"
|
|
4
|
-
"version": "7.0.0-dev.33",
|
|
3
|
+
"version": "7.0.0-dev.331",
|
|
5
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.",
|
|
6
|
-
"exports": {
|
|
7
|
-
"./package.json": "./package.json",
|
|
8
|
-
".": "./index.js"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+ssh://git@github.com/mikro-orm/mikro-orm.git"
|
|
13
|
-
},
|
|
14
5
|
"keywords": [
|
|
15
|
-
"
|
|
6
|
+
"data-mapper",
|
|
7
|
+
"ddd",
|
|
8
|
+
"entity",
|
|
9
|
+
"identity-map",
|
|
10
|
+
"javascript",
|
|
11
|
+
"js",
|
|
12
|
+
"mariadb",
|
|
13
|
+
"mikro-orm",
|
|
16
14
|
"mongo",
|
|
17
15
|
"mongodb",
|
|
18
16
|
"mysql",
|
|
19
|
-
"
|
|
17
|
+
"orm",
|
|
20
18
|
"postgresql",
|
|
21
19
|
"sqlite",
|
|
22
20
|
"sqlite3",
|
|
23
21
|
"ts",
|
|
24
22
|
"typescript",
|
|
25
|
-
"
|
|
26
|
-
"javascript",
|
|
27
|
-
"entity",
|
|
28
|
-
"ddd",
|
|
29
|
-
"mikro-orm",
|
|
30
|
-
"unit-of-work",
|
|
31
|
-
"data-mapper",
|
|
32
|
-
"identity-map"
|
|
23
|
+
"unit-of-work"
|
|
33
24
|
],
|
|
34
|
-
"
|
|
35
|
-
"license": "MIT",
|
|
25
|
+
"homepage": "https://mikro-orm.io",
|
|
36
26
|
"bugs": {
|
|
37
27
|
"url": "https://github.com/mikro-orm/mikro-orm/issues"
|
|
38
28
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"author": "Martin Adámek",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+ssh://git@github.com/mikro-orm/mikro-orm.git"
|
|
34
|
+
},
|
|
35
|
+
"type": "module",
|
|
36
|
+
"exports": {
|
|
37
|
+
"./package.json": "./package.json",
|
|
38
|
+
".": "./index.js"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
|
-
"build": "yarn
|
|
44
|
+
"build": "yarn compile && yarn copy",
|
|
45
45
|
"clean": "yarn run -T rimraf ./dist",
|
|
46
46
|
"compile": "yarn run -T tsc -p tsconfig.build.json",
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
|
-
"publishConfig": {
|
|
50
|
-
"access": "public"
|
|
51
|
-
},
|
|
52
49
|
"dependencies": {
|
|
53
|
-
"@mikro-orm/
|
|
54
|
-
"
|
|
50
|
+
"@mikro-orm/sql": "7.0.0-dev.331",
|
|
51
|
+
"kysely": "0.28.11",
|
|
52
|
+
"pg": "8.20.0",
|
|
53
|
+
"pg-cursor": "2.19.0",
|
|
55
54
|
"postgres-array": "3.0.4",
|
|
56
55
|
"postgres-date": "2.1.0",
|
|
57
56
|
"postgres-interval": "4.0.2"
|
|
58
57
|
},
|
|
59
58
|
"devDependencies": {
|
|
60
|
-
"@mikro-orm/core": "^6.
|
|
61
|
-
"kysely": "0.28.7"
|
|
59
|
+
"@mikro-orm/core": "^6.6.9"
|
|
62
60
|
},
|
|
63
61
|
"peerDependencies": {
|
|
64
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
65
|
-
|
|
62
|
+
"@mikro-orm/core": "7.0.0-dev.331"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">= 22.17.0"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/raw.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type AnyString, type Dictionary, type EntityKey, type RawQueryFragment } from '@mikro-orm/sql';
|
|
2
|
+
import type { SelectQueryBuilder as KyselySelectQueryBuilder } from 'kysely';
|
|
3
|
+
/** @internal Type for QueryBuilder instances passed to raw() - uses toRaw to distinguish from Kysely QueryBuilder */
|
|
4
|
+
type QueryBuilderLike = {
|
|
5
|
+
toQuery(): {
|
|
6
|
+
sql: string;
|
|
7
|
+
params: readonly unknown[];
|
|
8
|
+
};
|
|
9
|
+
toRaw(): RawQueryFragment;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Creates raw SQL query fragment that can be assigned to a property or part of a filter. This fragment is represented
|
|
13
|
+
* by `RawQueryFragment` class instance that can be serialized to a string, so it can be used both as an object value
|
|
14
|
+
* and key. When serialized, the fragment key gets cached and only such cached key will be recognized by the ORM.
|
|
15
|
+
* This adds a runtime safety to the raw query fragments.
|
|
16
|
+
*
|
|
17
|
+
* > **`raw()` helper is required since v6 to use a raw fragment in your query, both through EntityManager and QueryBuilder.**
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* // as a value
|
|
21
|
+
* await em.find(User, { time: raw('now()') });
|
|
22
|
+
*
|
|
23
|
+
* // as a key
|
|
24
|
+
* await em.find(User, { [raw('lower(name)')]: name.toLowerCase() });
|
|
25
|
+
*
|
|
26
|
+
* // value can be empty array
|
|
27
|
+
* await em.find(User, { [raw('(select 1 = 1)')]: [] });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* The `raw` helper supports several signatures, you can pass in a callback that receives the current property alias:
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* await em.find(User, { [raw(alias => `lower(${alias}.name)`)]: name.toLowerCase() });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* You can also use the `sql` tagged template function, which works the same, but supports only the simple string signature:
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* await em.find(User, { [sql`lower(name)`]: name.toLowerCase() });
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* When using inside filters, you might have to use a callback signature to create new raw instance for every filter usage.
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* @Filter({ name: 'long', cond: () => ({ [raw('length(perex)')]: { $gt: 10000 } }) })
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* The `raw` helper can be used within indexes and uniques to write database-agnostic SQL expressions. In that case, you can use `'??'` to tag your database identifiers (table name, column names, index name, ...) inside your expression, and pass those identifiers as a second parameter to the `raw` helper. Internally, those will automatically be quoted according to the database in use:
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* // On postgres, will produce: create index "index custom_idx_on_name" on "library.author" ("country")
|
|
52
|
+
* // On mysql, will produce: create index `index custom_idx_on_name` on `library.author` (`country`)
|
|
53
|
+
* @Index({ name: 'custom_idx_on_name', expression: (table, columns) => raw(`create index ?? on ?? (??)`, ['custom_idx_on_name', table, columns.name]) })
|
|
54
|
+
* @Entity({ schema: 'library' })
|
|
55
|
+
* export class Author { ... }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* You can also use the `quote` tag function to write database-agnostic SQL expressions. The end-result is the same as using the `raw` function regarding database identifiers quoting, only to have a more elegant expression syntax:
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* @Index({ name: 'custom_idx_on_name', expression: (table, columns) => quote`create index ${'custom_idx_on_name'} on ${table} (${columns.name})` })
|
|
62
|
+
* @Entity({ schema: 'library' })
|
|
63
|
+
* export class Author { ... }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function raw<R = RawQueryFragment & symbol, T extends object = any>(sql: QueryBuilderLike | KyselySelectQueryBuilder<any, any, any> | EntityKey<T> | EntityKey<T>[] | AnyString | ((alias: string) => string) | RawQueryFragment, params?: readonly unknown[] | Dictionary<unknown>): R;
|
|
67
|
+
export {};
|
package/raw.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { raw as raw_, Utils, } from '@mikro-orm/sql';
|
|
2
|
+
/**
|
|
3
|
+
* Creates raw SQL query fragment that can be assigned to a property or part of a filter. This fragment is represented
|
|
4
|
+
* by `RawQueryFragment` class instance that can be serialized to a string, so it can be used both as an object value
|
|
5
|
+
* and key. When serialized, the fragment key gets cached and only such cached key will be recognized by the ORM.
|
|
6
|
+
* This adds a runtime safety to the raw query fragments.
|
|
7
|
+
*
|
|
8
|
+
* > **`raw()` helper is required since v6 to use a raw fragment in your query, both through EntityManager and QueryBuilder.**
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* // as a value
|
|
12
|
+
* await em.find(User, { time: raw('now()') });
|
|
13
|
+
*
|
|
14
|
+
* // as a key
|
|
15
|
+
* await em.find(User, { [raw('lower(name)')]: name.toLowerCase() });
|
|
16
|
+
*
|
|
17
|
+
* // value can be empty array
|
|
18
|
+
* await em.find(User, { [raw('(select 1 = 1)')]: [] });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* The `raw` helper supports several signatures, you can pass in a callback that receives the current property alias:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* await em.find(User, { [raw(alias => `lower(${alias}.name)`)]: name.toLowerCase() });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* You can also use the `sql` tagged template function, which works the same, but supports only the simple string signature:
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* await em.find(User, { [sql`lower(name)`]: name.toLowerCase() });
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* When using inside filters, you might have to use a callback signature to create new raw instance for every filter usage.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* @Filter({ name: 'long', cond: () => ({ [raw('length(perex)')]: { $gt: 10000 } }) })
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* The `raw` helper can be used within indexes and uniques to write database-agnostic SQL expressions. In that case, you can use `'??'` to tag your database identifiers (table name, column names, index name, ...) inside your expression, and pass those identifiers as a second parameter to the `raw` helper. Internally, those will automatically be quoted according to the database in use:
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* // On postgres, will produce: create index "index custom_idx_on_name" on "library.author" ("country")
|
|
43
|
+
* // On mysql, will produce: create index `index custom_idx_on_name` on `library.author` (`country`)
|
|
44
|
+
* @Index({ name: 'custom_idx_on_name', expression: (table, columns) => raw(`create index ?? on ?? (??)`, ['custom_idx_on_name', table, columns.name]) })
|
|
45
|
+
* @Entity({ schema: 'library' })
|
|
46
|
+
* export class Author { ... }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* You can also use the `quote` tag function to write database-agnostic SQL expressions. The end-result is the same as using the `raw` function regarding database identifiers quoting, only to have a more elegant expression syntax:
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* @Index({ name: 'custom_idx_on_name', expression: (table, columns) => quote`create index ${'custom_idx_on_name'} on ${table} (${columns.name})` })
|
|
53
|
+
* @Entity({ schema: 'library' })
|
|
54
|
+
* export class Author { ... }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function raw(sql, params) {
|
|
58
|
+
if (Utils.isObject(sql) && 'compile' in sql) {
|
|
59
|
+
const query = sql.compile();
|
|
60
|
+
const processed = query.sql.replaceAll(/\$\d+/g, '?');
|
|
61
|
+
return raw_(processed, query.parameters);
|
|
62
|
+
}
|
|
63
|
+
return raw_(sql, params);
|
|
64
|
+
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ExceptionConverter, type Dictionary, type DriverException } from '@mikro-orm/core';
|
|
2
|
-
export declare class PostgreSqlExceptionConverter extends ExceptionConverter {
|
|
3
|
-
/**
|
|
4
|
-
* @link http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html
|
|
5
|
-
* @link https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
|
|
6
|
-
*/
|
|
7
|
-
convertException(exception: Error & Dictionary): DriverException;
|
|
8
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { DeadlockException, ExceptionConverter, ForeignKeyConstraintViolationException, InvalidFieldNameException, NonUniqueFieldNameException, NotNullConstraintViolationException, SyntaxErrorException, TableExistsException, TableNotFoundException, UniqueConstraintViolationException, CheckConstraintViolationException, } from '@mikro-orm/core';
|
|
2
|
-
export class PostgreSqlExceptionConverter extends ExceptionConverter {
|
|
3
|
-
/**
|
|
4
|
-
* @link http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html
|
|
5
|
-
* @link https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
|
|
6
|
-
*/
|
|
7
|
-
convertException(exception) {
|
|
8
|
-
if (exception.detail?.toString().trim()) {
|
|
9
|
-
exception.message += '\n - detail: ' + exception.detail;
|
|
10
|
-
}
|
|
11
|
-
if (exception.hint?.toString().trim()) {
|
|
12
|
-
exception.message += '\n - hint: ' + exception.hint;
|
|
13
|
-
}
|
|
14
|
-
/* v8 ignore start */
|
|
15
|
-
switch (exception.code) {
|
|
16
|
-
case '40001':
|
|
17
|
-
case '40P01':
|
|
18
|
-
return new DeadlockException(exception);
|
|
19
|
-
case '0A000':
|
|
20
|
-
// Foreign key constraint violations during a TRUNCATE operation
|
|
21
|
-
// are considered "feature not supported" in PostgreSQL.
|
|
22
|
-
if (exception.message.includes('truncate')) {
|
|
23
|
-
return new ForeignKeyConstraintViolationException(exception);
|
|
24
|
-
}
|
|
25
|
-
break;
|
|
26
|
-
case '23502':
|
|
27
|
-
return new NotNullConstraintViolationException(exception);
|
|
28
|
-
case '23503':
|
|
29
|
-
return new ForeignKeyConstraintViolationException(exception);
|
|
30
|
-
case '23505':
|
|
31
|
-
return new UniqueConstraintViolationException(exception);
|
|
32
|
-
case '23514':
|
|
33
|
-
return new CheckConstraintViolationException(exception);
|
|
34
|
-
case '42601':
|
|
35
|
-
return new SyntaxErrorException(exception);
|
|
36
|
-
case '42702':
|
|
37
|
-
return new NonUniqueFieldNameException(exception);
|
|
38
|
-
case '42703':
|
|
39
|
-
return new InvalidFieldNameException(exception);
|
|
40
|
-
case '42P01':
|
|
41
|
-
return new TableNotFoundException(exception);
|
|
42
|
-
case '42P07':
|
|
43
|
-
return new TableExistsException(exception);
|
|
44
|
-
}
|
|
45
|
-
/* v8 ignore stop */
|
|
46
|
-
return super.convertException(exception);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { type Dictionary } from '@mikro-orm/core';
|
|
2
|
-
import { SchemaHelper, type AbstractSqlConnection, type CheckDef, type Column, type DatabaseSchema, type DatabaseTable, type ForeignKey, type IndexDef, type Table, type TableDifference } from '@mikro-orm/knex';
|
|
3
|
-
export declare class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
4
|
-
static readonly DEFAULT_VALUES: {
|
|
5
|
-
'now()': string[];
|
|
6
|
-
'current_timestamp(?)': string[];
|
|
7
|
-
"('now'::text)::timestamp(?) with time zone": string[];
|
|
8
|
-
"('now'::text)::timestamp(?) without time zone": string[];
|
|
9
|
-
'null::character varying': string[];
|
|
10
|
-
'null::timestamp with time zone': string[];
|
|
11
|
-
'null::timestamp without time zone': string[];
|
|
12
|
-
};
|
|
13
|
-
getSchemaBeginning(charset: string, disableForeignKeys?: boolean): string;
|
|
14
|
-
getCreateDatabaseSQL(name: string): string;
|
|
15
|
-
getListTablesSQL(): string;
|
|
16
|
-
getNamespaces(connection: AbstractSqlConnection): Promise<string[]>;
|
|
17
|
-
private getIgnoredNamespacesConditionSQL;
|
|
18
|
-
loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[]): Promise<void>;
|
|
19
|
-
getAllIndexes(connection: AbstractSqlConnection, tables: Table[]): Promise<Dictionary<IndexDef[]>>;
|
|
20
|
-
getAllColumns(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>, nativeEnums?: Dictionary<{
|
|
21
|
-
name: string;
|
|
22
|
-
schema?: string;
|
|
23
|
-
items: string[];
|
|
24
|
-
}>): Promise<Dictionary<Column[]>>;
|
|
25
|
-
getAllChecks(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>): Promise<Dictionary<CheckDef[]>>;
|
|
26
|
-
getAllForeignKeys(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>): Promise<Dictionary<Dictionary<ForeignKey>>>;
|
|
27
|
-
getNativeEnumDefinitions(connection: AbstractSqlConnection, schemas: string[]): Promise<Dictionary<{
|
|
28
|
-
name: string;
|
|
29
|
-
schema?: string;
|
|
30
|
-
items: string[];
|
|
31
|
-
}>>;
|
|
32
|
-
getCreateNativeEnumSQL(name: string, values: unknown[], schema?: string): string;
|
|
33
|
-
getDropNativeEnumSQL(name: string, schema?: string): string;
|
|
34
|
-
getAlterNativeEnumSQL(name: string, schema?: string, value?: string, items?: string[], oldItems?: string[]): string;
|
|
35
|
-
private getEnumDefinitions;
|
|
36
|
-
createTableColumn(column: Column, table: DatabaseTable): string | undefined;
|
|
37
|
-
getPreAlterTable(tableDiff: TableDifference, safe: boolean): string[];
|
|
38
|
-
castColumn(name: string, type: string): string;
|
|
39
|
-
dropForeignKey(tableName: string, constraintName: string): string;
|
|
40
|
-
getPostAlterTable(tableDiff: TableDifference, safe: boolean): string[];
|
|
41
|
-
private getAlterColumnAutoincrement;
|
|
42
|
-
getChangeColumnCommentSQL(tableName: string, to: Column, schemaName?: string): string;
|
|
43
|
-
alterTableComment(table: DatabaseTable, comment?: string): string;
|
|
44
|
-
normalizeDefaultValue(defaultValue: string, length: number): string | number;
|
|
45
|
-
appendComments(table: DatabaseTable): string[];
|
|
46
|
-
getDatabaseExistsSQL(name: string): string;
|
|
47
|
-
getDatabaseNotExistsError(dbName: string): string;
|
|
48
|
-
getManagementDbName(): string;
|
|
49
|
-
disableForeignKeysSQL(): string;
|
|
50
|
-
enableForeignKeysSQL(): string;
|
|
51
|
-
getRenameIndexSQL(tableName: string, index: IndexDef, oldIndexName: string): string[];
|
|
52
|
-
dropIndex(table: string, index: IndexDef, oldIndexName?: string): string;
|
|
53
|
-
private getIndexesSQL;
|
|
54
|
-
private getChecksSQL;
|
|
55
|
-
inferLengthFromColumnType(type: string): number | undefined;
|
|
56
|
-
}
|