@uql/core 3.8.1 → 3.8.3
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/CHANGELOG.md +16 -1
- package/README.md +1 -0
- package/dist/dialect/abstractSqlDialect.d.ts +2 -1
- package/dist/dialect/abstractSqlDialect.d.ts.map +1 -1
- package/dist/dialect/abstractSqlDialect.js.map +1 -1
- package/dist/dialect/dialectConfig.d.ts +9 -3
- package/dist/dialect/dialectConfig.d.ts.map +1 -1
- package/dist/dialect/dialectConfig.js +50 -25
- package/dist/dialect/dialectConfig.js.map +1 -1
- package/dist/migrate/builder/columnBuilder.d.ts +4 -0
- package/dist/migrate/builder/columnBuilder.d.ts.map +1 -1
- package/dist/migrate/builder/columnBuilder.js +10 -0
- package/dist/migrate/builder/columnBuilder.js.map +1 -1
- package/dist/migrate/builder/expressions.js +1 -1
- package/dist/migrate/builder/expressions.js.map +1 -1
- package/dist/migrate/builder/migrationBuilder.d.ts +64 -28
- package/dist/migrate/builder/migrationBuilder.d.ts.map +1 -1
- package/dist/migrate/builder/migrationBuilder.js +200 -67
- package/dist/migrate/builder/migrationBuilder.js.map +1 -1
- package/dist/migrate/builder/tableBuilder.d.ts.map +1 -1
- package/dist/migrate/builder/tableBuilder.js +13 -0
- package/dist/migrate/builder/tableBuilder.js.map +1 -1
- package/dist/migrate/builder/types.d.ts +4 -0
- package/dist/migrate/builder/types.d.ts.map +1 -1
- package/dist/migrate/codegen/entityCodeGenerator.d.ts.map +1 -1
- package/dist/migrate/codegen/entityCodeGenerator.js +12 -8
- package/dist/migrate/codegen/entityCodeGenerator.js.map +1 -1
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +77 -0
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts.map +1 -0
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +156 -0
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js.map +1 -0
- package/dist/migrate/introspection/index.d.ts +1 -0
- package/dist/migrate/introspection/index.d.ts.map +1 -1
- package/dist/migrate/introspection/index.js +1 -0
- package/dist/migrate/introspection/index.js.map +1 -1
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +16 -14
- package/dist/migrate/introspection/mysqlIntrospector.d.ts.map +1 -1
- package/dist/migrate/introspection/mysqlIntrospector.js +68 -118
- package/dist/migrate/introspection/mysqlIntrospector.js.map +1 -1
- package/dist/migrate/introspection/postgresIntrospector.d.ts +17 -15
- package/dist/migrate/introspection/postgresIntrospector.d.ts.map +1 -1
- package/dist/migrate/introspection/postgresIntrospector.js +86 -128
- package/dist/migrate/introspection/postgresIntrospector.js.map +1 -1
- package/dist/migrate/introspection/sqliteIntrospector.d.ts +20 -14
- package/dist/migrate/introspection/sqliteIntrospector.d.ts.map +1 -1
- package/dist/migrate/introspection/sqliteIntrospector.js +88 -122
- package/dist/migrate/introspection/sqliteIntrospector.js.map +1 -1
- package/dist/migrate/schemaGenerator.d.ts +1 -13
- package/dist/migrate/schemaGenerator.d.ts.map +1 -1
- package/dist/migrate/schemaGenerator.js +17 -76
- package/dist/migrate/schemaGenerator.js.map +1 -1
- package/dist/schema/schemaASTBuilder.d.ts.map +1 -1
- package/dist/schema/schemaASTBuilder.js +31 -0
- package/dist/schema/schemaASTBuilder.js.map +1 -1
- package/dist/type/migration.d.ts +4 -0
- package/dist/type/migration.d.ts.map +1 -1
- package/dist/type/querier.d.ts +2 -5
- package/dist/type/querier.d.ts.map +1 -1
- package/dist/type/querier.js.map +1 -1
- package/dist/type/query.d.ts +8 -0
- package/dist/type/query.d.ts.map +1 -1
- package/package.json +2 -3
|
@@ -1,86 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseSqlIntrospector } from './baseSqlIntrospector.js';
|
|
1
|
+
import { AbstractSqlSchemaIntrospector } from './abstractSqlSchemaIntrospector.js';
|
|
3
2
|
/**
|
|
4
3
|
* MySQL/MariaDB schema introspector.
|
|
5
4
|
* Works with both MySQL and MariaDB as they share the same information_schema structure.
|
|
6
5
|
*/
|
|
7
|
-
export class MysqlSchemaIntrospector extends
|
|
6
|
+
export class MysqlSchemaIntrospector extends AbstractSqlSchemaIntrospector {
|
|
8
7
|
pool;
|
|
9
8
|
constructor(pool) {
|
|
10
9
|
super('mysql');
|
|
11
10
|
this.pool = pool;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.getPrimaryKey(querier, tableName),
|
|
25
|
-
]);
|
|
26
|
-
return {
|
|
27
|
-
name: tableName,
|
|
28
|
-
columns,
|
|
29
|
-
primaryKey,
|
|
30
|
-
indexes,
|
|
31
|
-
foreignKeys,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
finally {
|
|
35
|
-
await querier.release();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async getTableNames() {
|
|
39
|
-
const querier = await this.getQuerier();
|
|
40
|
-
try {
|
|
41
|
-
const sql = `
|
|
42
|
-
SELECT TABLE_NAME as table_name
|
|
43
|
-
FROM information_schema.TABLES
|
|
44
|
-
WHERE TABLE_SCHEMA = DATABASE()
|
|
45
|
-
AND TABLE_TYPE = 'BASE TABLE'
|
|
46
|
-
ORDER BY TABLE_NAME
|
|
47
|
-
`;
|
|
48
|
-
const results = await querier.all(sql);
|
|
49
|
-
return results.map((r) => r.table_name);
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
await querier.release();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async tableExists(tableName) {
|
|
56
|
-
const querier = await this.getQuerier();
|
|
57
|
-
try {
|
|
58
|
-
return this.tableExistsInternal(querier, tableName);
|
|
59
|
-
}
|
|
60
|
-
finally {
|
|
61
|
-
await querier.release();
|
|
62
|
-
}
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// SQL Queries (dialect-specific)
|
|
14
|
+
// ============================================================================
|
|
15
|
+
getTableNamesQuery() {
|
|
16
|
+
return /*sql*/ `
|
|
17
|
+
SELECT TABLE_NAME as table_name
|
|
18
|
+
FROM information_schema.TABLES
|
|
19
|
+
WHERE TABLE_SCHEMA = DATABASE()
|
|
20
|
+
AND TABLE_TYPE = 'BASE TABLE'
|
|
21
|
+
ORDER BY TABLE_NAME
|
|
22
|
+
`;
|
|
63
23
|
}
|
|
64
|
-
|
|
65
|
-
|
|
24
|
+
tableExistsQuery() {
|
|
25
|
+
return /*sql*/ `
|
|
66
26
|
SELECT COUNT(*) as count
|
|
67
27
|
FROM information_schema.TABLES
|
|
68
28
|
WHERE TABLE_SCHEMA = DATABASE()
|
|
69
29
|
AND TABLE_NAME = ?
|
|
70
30
|
`;
|
|
71
|
-
const results = await querier.all(sql, [tableName]);
|
|
72
|
-
return (results[0]?.count ?? 0) > 0;
|
|
73
31
|
}
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
await querier.release();
|
|
78
|
-
throw new Error('MysqlSchemaIntrospector requires a SQL-based querier');
|
|
79
|
-
}
|
|
80
|
-
return querier;
|
|
32
|
+
parseTableExistsResult(results) {
|
|
33
|
+
const count = results[0]?.count;
|
|
34
|
+
return (typeof count === 'number' || typeof count === 'bigint' ? Number(count) : 0) > 0;
|
|
81
35
|
}
|
|
82
|
-
|
|
83
|
-
|
|
36
|
+
getColumnsQuery(_tableName) {
|
|
37
|
+
return /*sql*/ `
|
|
84
38
|
SELECT
|
|
85
39
|
COLUMN_NAME as column_name,
|
|
86
40
|
DATA_TYPE as data_type,
|
|
@@ -98,23 +52,9 @@ export class MysqlSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
98
52
|
AND TABLE_NAME = ?
|
|
99
53
|
ORDER BY ORDINAL_POSITION
|
|
100
54
|
`;
|
|
101
|
-
const results = await querier.all(sql, [tableName]);
|
|
102
|
-
return results.map((row) => ({
|
|
103
|
-
name: row.column_name,
|
|
104
|
-
type: (row.column_type || '').toUpperCase(),
|
|
105
|
-
nullable: row.is_nullable === 'YES',
|
|
106
|
-
defaultValue: this.parseDefaultValue(row.column_default),
|
|
107
|
-
isPrimaryKey: row.column_key === 'PRI',
|
|
108
|
-
isAutoIncrement: (row.extra || '').toLowerCase().includes('auto_increment'),
|
|
109
|
-
isUnique: row.column_key === 'UNI',
|
|
110
|
-
length: row.character_maximum_length ?? undefined,
|
|
111
|
-
precision: row.numeric_precision ?? undefined,
|
|
112
|
-
scale: row.numeric_scale ?? undefined,
|
|
113
|
-
comment: row.column_comment || undefined,
|
|
114
|
-
}));
|
|
115
55
|
}
|
|
116
|
-
|
|
117
|
-
|
|
56
|
+
getIndexesQuery(_tableName) {
|
|
57
|
+
return /*sql*/ `
|
|
118
58
|
SELECT
|
|
119
59
|
INDEX_NAME as index_name,
|
|
120
60
|
GROUP_CONCAT(COLUMN_NAME ORDER BY SEQ_IN_INDEX) as columns,
|
|
@@ -126,15 +66,9 @@ export class MysqlSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
126
66
|
GROUP BY INDEX_NAME, NON_UNIQUE
|
|
127
67
|
ORDER BY INDEX_NAME
|
|
128
68
|
`;
|
|
129
|
-
const results = await querier.all(sql, [tableName]);
|
|
130
|
-
return results.map((row) => ({
|
|
131
|
-
name: row.index_name,
|
|
132
|
-
columns: (row.columns || '').split(','),
|
|
133
|
-
unique: Boolean(row.is_unique),
|
|
134
|
-
}));
|
|
135
69
|
}
|
|
136
|
-
|
|
137
|
-
|
|
70
|
+
getForeignKeysQuery(_tableName) {
|
|
71
|
+
return /*sql*/ `
|
|
138
72
|
SELECT
|
|
139
73
|
kcu.CONSTRAINT_NAME as constraint_name,
|
|
140
74
|
GROUP_CONCAT(kcu.COLUMN_NAME ORDER BY kcu.ORDINAL_POSITION) as columns,
|
|
@@ -152,7 +86,46 @@ export class MysqlSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
152
86
|
GROUP BY kcu.CONSTRAINT_NAME, kcu.REFERENCED_TABLE_NAME, rc.DELETE_RULE, rc.UPDATE_RULE
|
|
153
87
|
ORDER BY kcu.CONSTRAINT_NAME
|
|
154
88
|
`;
|
|
155
|
-
|
|
89
|
+
}
|
|
90
|
+
getPrimaryKeyQuery(_tableName) {
|
|
91
|
+
return /*sql*/ `
|
|
92
|
+
SELECT COLUMN_NAME as column_name
|
|
93
|
+
FROM information_schema.KEY_COLUMN_USAGE
|
|
94
|
+
WHERE TABLE_SCHEMA = DATABASE()
|
|
95
|
+
AND TABLE_NAME = ?
|
|
96
|
+
AND CONSTRAINT_NAME = 'PRIMARY'
|
|
97
|
+
ORDER BY ORDINAL_POSITION
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
// ============================================================================
|
|
101
|
+
// Row Mapping (dialect-specific)
|
|
102
|
+
// ============================================================================
|
|
103
|
+
mapTableNameRow(row) {
|
|
104
|
+
return row.table_name;
|
|
105
|
+
}
|
|
106
|
+
async mapColumnsResult(_querier, _tableName, results) {
|
|
107
|
+
return results.map((row) => ({
|
|
108
|
+
name: row.column_name,
|
|
109
|
+
type: (row.column_type || '').toUpperCase(),
|
|
110
|
+
nullable: row.is_nullable === 'YES',
|
|
111
|
+
defaultValue: this.parseDefaultValue(row.column_default),
|
|
112
|
+
isPrimaryKey: row.column_key === 'PRI',
|
|
113
|
+
isAutoIncrement: (row.extra || '').toLowerCase().includes('auto_increment'),
|
|
114
|
+
isUnique: row.column_key === 'UNI',
|
|
115
|
+
length: this.toNumber(row.character_maximum_length),
|
|
116
|
+
precision: this.toNumber(row.numeric_precision),
|
|
117
|
+
scale: this.toNumber(row.numeric_scale),
|
|
118
|
+
comment: row.column_comment || undefined,
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
async mapIndexesResult(_querier, _tableName, results) {
|
|
122
|
+
return results.map((row) => ({
|
|
123
|
+
name: row.index_name,
|
|
124
|
+
columns: (row.columns || '').split(','),
|
|
125
|
+
unique: Boolean(row.is_unique),
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
async mapForeignKeysResult(_querier, _tableName, results) {
|
|
156
129
|
return results.map((row) => ({
|
|
157
130
|
name: row.constraint_name,
|
|
158
131
|
columns: (row.columns || '').split(','),
|
|
@@ -162,16 +135,7 @@ export class MysqlSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
162
135
|
onUpdate: this.normalizeReferentialAction(row.update_rule),
|
|
163
136
|
}));
|
|
164
137
|
}
|
|
165
|
-
|
|
166
|
-
const sql = `
|
|
167
|
-
SELECT COLUMN_NAME as column_name
|
|
168
|
-
FROM information_schema.KEY_COLUMN_USAGE
|
|
169
|
-
WHERE TABLE_SCHEMA = DATABASE()
|
|
170
|
-
AND TABLE_NAME = ?
|
|
171
|
-
AND CONSTRAINT_NAME = 'PRIMARY'
|
|
172
|
-
ORDER BY ORDINAL_POSITION
|
|
173
|
-
`;
|
|
174
|
-
const results = await querier.all(sql, [tableName]);
|
|
138
|
+
mapPrimaryKeyResult(results) {
|
|
175
139
|
if (results.length === 0) {
|
|
176
140
|
return undefined;
|
|
177
141
|
}
|
|
@@ -181,12 +145,12 @@ export class MysqlSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
181
145
|
if (defaultValue === null) {
|
|
182
146
|
return undefined;
|
|
183
147
|
}
|
|
184
|
-
// Check for common patterns
|
|
185
148
|
if (defaultValue === 'NULL') {
|
|
186
149
|
return null;
|
|
187
150
|
}
|
|
188
|
-
|
|
189
|
-
|
|
151
|
+
// Normalize timestamp defaults (MariaDB uses current_timestamp(), MySQL uses CURRENT_TIMESTAMP)
|
|
152
|
+
if (defaultValue.toLowerCase() === 'current_timestamp' || defaultValue.toLowerCase() === 'current_timestamp()') {
|
|
153
|
+
return 'CURRENT_TIMESTAMP';
|
|
190
154
|
}
|
|
191
155
|
if (/^'.*'$/.test(defaultValue)) {
|
|
192
156
|
return defaultValue.slice(1, -1);
|
|
@@ -199,20 +163,6 @@ export class MysqlSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
199
163
|
}
|
|
200
164
|
return defaultValue;
|
|
201
165
|
}
|
|
202
|
-
normalizeReferentialAction(action) {
|
|
203
|
-
switch (action.toUpperCase()) {
|
|
204
|
-
case 'CASCADE':
|
|
205
|
-
return 'CASCADE';
|
|
206
|
-
case 'SET NULL':
|
|
207
|
-
return 'SET NULL';
|
|
208
|
-
case 'RESTRICT':
|
|
209
|
-
return 'RESTRICT';
|
|
210
|
-
case 'NO ACTION':
|
|
211
|
-
return 'NO ACTION';
|
|
212
|
-
default:
|
|
213
|
-
return undefined;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
166
|
}
|
|
217
167
|
/**
|
|
218
168
|
* Alias for MysqlSchemaIntrospector.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mysqlIntrospector.js","sourceRoot":"","sources":["../../../src/migrate/introspection/mysqlIntrospector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mysqlIntrospector.js","sourceRoot":"","sources":["../../../src/migrate/introspection/mysqlIntrospector.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import type { ColumnSchema, ForeignKeySchema, IndexSchema, QuerierPool,
|
|
2
|
-
import {
|
|
1
|
+
import type { ColumnSchema, ForeignKeySchema, IndexSchema, QuerierPool, SqlQuerier } from '../../type/index.js';
|
|
2
|
+
import { AbstractSqlSchemaIntrospector } from './abstractSqlSchemaIntrospector.js';
|
|
3
3
|
/**
|
|
4
4
|
* PostgreSQL schema introspector
|
|
5
5
|
*/
|
|
6
|
-
export declare class PostgresSchemaIntrospector extends
|
|
7
|
-
|
|
6
|
+
export declare class PostgresSchemaIntrospector extends AbstractSqlSchemaIntrospector {
|
|
7
|
+
protected readonly pool: QuerierPool;
|
|
8
8
|
constructor(pool: QuerierPool);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
protected
|
|
13
|
-
protected
|
|
14
|
-
protected
|
|
15
|
-
protected
|
|
16
|
-
protected
|
|
17
|
-
protected
|
|
9
|
+
protected getTableNamesQuery(): string;
|
|
10
|
+
protected tableExistsQuery(): string;
|
|
11
|
+
protected parseTableExistsResult(results: Record<string, unknown>[]): boolean;
|
|
12
|
+
protected getColumnsQuery(_tableName: string): string;
|
|
13
|
+
protected getIndexesQuery(_tableName: string): string;
|
|
14
|
+
protected getForeignKeysQuery(_tableName: string): string;
|
|
15
|
+
protected getPrimaryKeyQuery(_tableName: string): string;
|
|
16
|
+
protected mapTableNameRow(row: Record<string, unknown>): string;
|
|
17
|
+
protected mapColumnsResult(_querier: SqlQuerier, _tableName: string, results: Record<string, unknown>[]): Promise<ColumnSchema[]>;
|
|
18
|
+
protected mapIndexesResult(_querier: SqlQuerier, _tableName: string, results: Record<string, unknown>[]): Promise<IndexSchema[]>;
|
|
19
|
+
protected mapForeignKeysResult(_querier: SqlQuerier, _tableName: string, results: Record<string, unknown>[]): Promise<ForeignKeySchema[]>;
|
|
20
|
+
protected mapPrimaryKeyResult(results: Record<string, unknown>[]): string[] | undefined;
|
|
18
21
|
protected normalizeType(dataType: string, udtName: string): string;
|
|
19
22
|
protected parseDefaultValue(defaultValue: string | null): unknown;
|
|
20
|
-
protected isAutoIncrement(defaultValue: string | null): boolean;
|
|
21
|
-
protected normalizeReferentialAction(action: string): 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION' | undefined;
|
|
23
|
+
protected isAutoIncrement(defaultValue: string | null, isIdentity: string): boolean;
|
|
22
24
|
}
|
|
23
25
|
//# sourceMappingURL=postgresIntrospector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgresIntrospector.d.ts","sourceRoot":"","sources":["../../../src/migrate/introspection/postgresIntrospector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"postgresIntrospector.d.ts","sourceRoot":"","sources":["../../../src/migrate/introspection/postgresIntrospector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAChH,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,6BAA6B;IAC3E,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;gBAEzB,IAAI,EAAE,WAAW;IAS7B,SAAS,CAAC,kBAAkB,IAAI,MAAM;IAUtC,SAAS,CAAC,gBAAgB,IAAI,MAAM;IAUpC,SAAS,CAAC,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,OAAO;IAI7E,SAAS,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IA4CrD,SAAS,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAoBrD,SAAS,CAAC,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IA2BzD,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAkBxD,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;cAI/C,gBAAgB,CAC9B,QAAQ,EAAE,UAAU,EACpB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACjC,OAAO,CAAC,YAAY,EAAE,CAAC;cAgBV,gBAAgB,CAC9B,QAAQ,EAAE,UAAU,EACpB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACjC,OAAO,CAAC,WAAW,EAAE,CAAC;cAQT,oBAAoB,CAClC,QAAQ,EAAE,UAAU,EACpB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACjC,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAW9B,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS;IAWvF,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAWlE,SAAS,CAAC,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;IA4BjE,SAAS,CAAC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO;CAWpF"}
|
|
@@ -1,86 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseSqlIntrospector } from './baseSqlIntrospector.js';
|
|
1
|
+
import { AbstractSqlSchemaIntrospector } from './abstractSqlSchemaIntrospector.js';
|
|
3
2
|
/**
|
|
4
3
|
* PostgreSQL schema introspector
|
|
5
4
|
*/
|
|
6
|
-
export class PostgresSchemaIntrospector extends
|
|
5
|
+
export class PostgresSchemaIntrospector extends AbstractSqlSchemaIntrospector {
|
|
7
6
|
pool;
|
|
8
7
|
constructor(pool) {
|
|
9
8
|
super('postgres');
|
|
10
9
|
this.pool = pool;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.getPrimaryKey(querier, tableName),
|
|
24
|
-
]);
|
|
25
|
-
return {
|
|
26
|
-
name: tableName,
|
|
27
|
-
columns,
|
|
28
|
-
primaryKey,
|
|
29
|
-
indexes,
|
|
30
|
-
foreignKeys,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
finally {
|
|
34
|
-
await querier.release();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async getTableNames() {
|
|
38
|
-
const querier = await this.getQuerier();
|
|
39
|
-
try {
|
|
40
|
-
const sql = `
|
|
41
|
-
SELECT table_name
|
|
42
|
-
FROM information_schema.tables
|
|
43
|
-
WHERE table_schema = 'public'
|
|
44
|
-
AND table_type = 'BASE TABLE'
|
|
45
|
-
ORDER BY table_name
|
|
46
|
-
`;
|
|
47
|
-
const results = await querier.all(sql);
|
|
48
|
-
return results.map((r) => r.table_name);
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
await querier.release();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async tableExists(tableName) {
|
|
55
|
-
const querier = await this.getQuerier();
|
|
56
|
-
try {
|
|
57
|
-
return this.tableExistsInternal(querier, tableName);
|
|
58
|
-
}
|
|
59
|
-
finally {
|
|
60
|
-
await querier.release();
|
|
61
|
-
}
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// SQL Queries (dialect-specific)
|
|
13
|
+
// ============================================================================
|
|
14
|
+
getTableNamesQuery() {
|
|
15
|
+
return /*sql*/ `
|
|
16
|
+
SELECT table_name
|
|
17
|
+
FROM information_schema.tables
|
|
18
|
+
WHERE table_schema = 'public'
|
|
19
|
+
AND table_type = 'BASE TABLE'
|
|
20
|
+
ORDER BY table_name
|
|
21
|
+
`;
|
|
62
22
|
}
|
|
63
|
-
|
|
64
|
-
|
|
23
|
+
tableExistsQuery() {
|
|
24
|
+
return /*sql*/ `
|
|
65
25
|
SELECT EXISTS (
|
|
66
26
|
SELECT FROM information_schema.tables
|
|
67
27
|
WHERE table_schema = 'public'
|
|
68
28
|
AND table_name = $1
|
|
69
29
|
) AS exists
|
|
70
30
|
`;
|
|
71
|
-
const results = await querier.all(sql, [tableName]);
|
|
72
|
-
return results[0]?.exists ?? false;
|
|
73
31
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (!isSqlQuerier(querier)) {
|
|
77
|
-
await querier.release();
|
|
78
|
-
throw new Error('PostgresSchemaIntrospector requires a SQL-based querier');
|
|
79
|
-
}
|
|
80
|
-
return querier;
|
|
32
|
+
parseTableExistsResult(results) {
|
|
33
|
+
return results[0]?.exists ?? false;
|
|
81
34
|
}
|
|
82
|
-
|
|
83
|
-
|
|
35
|
+
getColumnsQuery(_tableName) {
|
|
36
|
+
return /*sql*/ `
|
|
84
37
|
SELECT
|
|
85
38
|
c.column_name,
|
|
86
39
|
c.data_type,
|
|
@@ -90,6 +43,8 @@ export class PostgresSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
90
43
|
c.character_maximum_length,
|
|
91
44
|
c.numeric_precision,
|
|
92
45
|
c.numeric_scale,
|
|
46
|
+
c.is_identity,
|
|
47
|
+
c.identity_generation,
|
|
93
48
|
COALESCE(
|
|
94
49
|
(SELECT TRUE FROM information_schema.table_constraints tc
|
|
95
50
|
JOIN information_schema.key_column_usage kcu
|
|
@@ -119,26 +74,12 @@ export class PostgresSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
119
74
|
AND c.table_name = $1
|
|
120
75
|
ORDER BY c.ordinal_position
|
|
121
76
|
`;
|
|
122
|
-
const results = await querier.all(sql, [tableName]);
|
|
123
|
-
return results.map((row) => ({
|
|
124
|
-
name: row.column_name,
|
|
125
|
-
type: this.normalizeType(row.data_type, row.udt_name),
|
|
126
|
-
nullable: row.is_nullable === 'YES',
|
|
127
|
-
defaultValue: this.parseDefaultValue(row.column_default),
|
|
128
|
-
isPrimaryKey: row.is_primary_key,
|
|
129
|
-
isAutoIncrement: this.isAutoIncrement(row.column_default),
|
|
130
|
-
isUnique: row.is_unique,
|
|
131
|
-
length: row.character_maximum_length ?? undefined,
|
|
132
|
-
precision: row.numeric_precision ?? undefined,
|
|
133
|
-
scale: row.numeric_scale ?? undefined,
|
|
134
|
-
comment: row.column_comment ?? undefined,
|
|
135
|
-
}));
|
|
136
77
|
}
|
|
137
|
-
|
|
138
|
-
|
|
78
|
+
getIndexesQuery(_tableName) {
|
|
79
|
+
return /*sql*/ `
|
|
139
80
|
SELECT
|
|
140
81
|
i.relname AS index_name,
|
|
141
|
-
array_agg(a.attname ORDER BY k.n) AS columns,
|
|
82
|
+
array_to_json(array_agg(a.attname ORDER BY k.n)) AS columns,
|
|
142
83
|
ix.indisunique AS is_unique
|
|
143
84
|
FROM pg_class t
|
|
144
85
|
JOIN pg_index ix ON t.oid = ix.indrelid
|
|
@@ -152,20 +93,14 @@ export class PostgresSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
152
93
|
GROUP BY i.relname, ix.indisunique
|
|
153
94
|
ORDER BY i.relname
|
|
154
95
|
`;
|
|
155
|
-
const results = await querier.all(sql, [tableName]);
|
|
156
|
-
return results.map((row) => ({
|
|
157
|
-
name: row.index_name,
|
|
158
|
-
columns: row.columns,
|
|
159
|
-
unique: row.is_unique,
|
|
160
|
-
}));
|
|
161
96
|
}
|
|
162
|
-
|
|
163
|
-
|
|
97
|
+
getForeignKeysQuery(_tableName) {
|
|
98
|
+
return /*sql*/ `
|
|
164
99
|
SELECT
|
|
165
100
|
tc.constraint_name,
|
|
166
|
-
array_agg(kcu.column_name ORDER BY kcu.ordinal_position) AS columns,
|
|
101
|
+
array_to_json(array_agg(kcu.column_name ORDER BY kcu.ordinal_position)) AS columns,
|
|
167
102
|
ccu.table_name AS referenced_table,
|
|
168
|
-
array_agg(ccu.column_name ORDER BY kcu.ordinal_position) AS referenced_columns,
|
|
103
|
+
array_to_json(array_agg(ccu.column_name ORDER BY kcu.ordinal_position)) AS referenced_columns,
|
|
169
104
|
rc.delete_rule,
|
|
170
105
|
rc.update_rule
|
|
171
106
|
FROM information_schema.table_constraints tc
|
|
@@ -184,18 +119,9 @@ export class PostgresSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
184
119
|
GROUP BY tc.constraint_name, ccu.table_name, rc.delete_rule, rc.update_rule
|
|
185
120
|
ORDER BY tc.constraint_name
|
|
186
121
|
`;
|
|
187
|
-
const results = await querier.all(sql, [tableName]);
|
|
188
|
-
return results.map((row) => ({
|
|
189
|
-
name: row.constraint_name,
|
|
190
|
-
columns: row.columns,
|
|
191
|
-
referencedTable: row.referenced_table,
|
|
192
|
-
referencedColumns: row.referenced_columns,
|
|
193
|
-
onDelete: this.normalizeReferentialAction(row.delete_rule),
|
|
194
|
-
onUpdate: this.normalizeReferentialAction(row.update_rule),
|
|
195
|
-
}));
|
|
196
122
|
}
|
|
197
|
-
|
|
198
|
-
|
|
123
|
+
getPrimaryKeyQuery(_tableName) {
|
|
124
|
+
return /*sql*/ `
|
|
199
125
|
SELECT kcu.column_name
|
|
200
126
|
FROM information_schema.table_constraints tc
|
|
201
127
|
JOIN information_schema.key_column_usage kcu
|
|
@@ -206,19 +132,61 @@ export class PostgresSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
206
132
|
AND tc.table_schema = 'public'
|
|
207
133
|
ORDER BY kcu.ordinal_position
|
|
208
134
|
`;
|
|
209
|
-
|
|
135
|
+
}
|
|
136
|
+
// ============================================================================
|
|
137
|
+
// Row Mapping (dialect-specific)
|
|
138
|
+
// ============================================================================
|
|
139
|
+
mapTableNameRow(row) {
|
|
140
|
+
return row.table_name;
|
|
141
|
+
}
|
|
142
|
+
async mapColumnsResult(_querier, _tableName, results) {
|
|
143
|
+
return results.map((row) => ({
|
|
144
|
+
name: row.column_name,
|
|
145
|
+
type: this.normalizeType(row.data_type, row.udt_name),
|
|
146
|
+
nullable: row.is_nullable === 'YES',
|
|
147
|
+
defaultValue: this.parseDefaultValue(row.column_default),
|
|
148
|
+
isPrimaryKey: row.is_primary_key,
|
|
149
|
+
isAutoIncrement: this.isAutoIncrement(row.column_default, row.is_identity),
|
|
150
|
+
isUnique: row.is_unique,
|
|
151
|
+
length: row.character_maximum_length ?? undefined,
|
|
152
|
+
precision: row.numeric_precision ?? undefined,
|
|
153
|
+
scale: row.numeric_scale ?? undefined,
|
|
154
|
+
comment: row.column_comment ?? undefined,
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
async mapIndexesResult(_querier, _tableName, results) {
|
|
158
|
+
return results.map((row) => ({
|
|
159
|
+
name: row.index_name,
|
|
160
|
+
columns: row.columns,
|
|
161
|
+
unique: row.is_unique,
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
async mapForeignKeysResult(_querier, _tableName, results) {
|
|
165
|
+
return results.map((row) => ({
|
|
166
|
+
name: row.constraint_name,
|
|
167
|
+
columns: row.columns,
|
|
168
|
+
referencedTable: row.referenced_table,
|
|
169
|
+
referencedColumns: row.referenced_columns,
|
|
170
|
+
onDelete: this.normalizeReferentialAction(row.delete_rule),
|
|
171
|
+
onUpdate: this.normalizeReferentialAction(row.update_rule),
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
mapPrimaryKeyResult(results) {
|
|
210
175
|
if (results.length === 0) {
|
|
211
176
|
return undefined;
|
|
212
177
|
}
|
|
213
178
|
return results.map((r) => r.column_name);
|
|
214
179
|
}
|
|
180
|
+
// ============================================================================
|
|
181
|
+
// PostgreSQL-specific helpers
|
|
182
|
+
// ============================================================================
|
|
215
183
|
normalizeType(dataType, udtName) {
|
|
216
184
|
// Handle user-defined types and arrays
|
|
217
185
|
if (dataType === 'USER-DEFINED') {
|
|
218
186
|
return udtName.toUpperCase();
|
|
219
187
|
}
|
|
220
188
|
if (dataType === 'ARRAY') {
|
|
221
|
-
return `${udtName.replace(/^_/, '')}[]`;
|
|
189
|
+
return `${udtName.replace(/^_/, '').toUpperCase()}[]`;
|
|
222
190
|
}
|
|
223
191
|
return dataType.toUpperCase();
|
|
224
192
|
}
|
|
@@ -226,9 +194,8 @@ export class PostgresSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
226
194
|
if (!defaultValue) {
|
|
227
195
|
return undefined;
|
|
228
196
|
}
|
|
229
|
-
// Remove type casting
|
|
230
|
-
const cleaned = defaultValue.replace(/::[a-z_]+(\[\])?/gi, '').trim();
|
|
231
|
-
// Check for common patterns
|
|
197
|
+
// Remove type casting (e.g., ::text, ::character varying, ::text[])
|
|
198
|
+
const cleaned = defaultValue.replace(/::[a-z_]+(\s+[a-z_]+)?(\[\])?/gi, '').trim();
|
|
232
199
|
if (cleaned.startsWith("'") && cleaned.endsWith("'")) {
|
|
233
200
|
return cleaned.slice(1, -1);
|
|
234
201
|
}
|
|
@@ -244,28 +211,19 @@ export class PostgresSchemaIntrospector extends BaseSqlIntrospector {
|
|
|
244
211
|
if (/^-?\d+\.\d+$/.test(cleaned)) {
|
|
245
212
|
return Number.parseFloat(cleaned);
|
|
246
213
|
}
|
|
247
|
-
// Return
|
|
248
|
-
return
|
|
214
|
+
// Return cleaned value for functions like CURRENT_TIMESTAMP, nextval(), etc.
|
|
215
|
+
return cleaned;
|
|
249
216
|
}
|
|
250
|
-
isAutoIncrement(defaultValue) {
|
|
251
|
-
|
|
252
|
-
|
|
217
|
+
isAutoIncrement(defaultValue, isIdentity) {
|
|
218
|
+
// PostgreSQL identity columns (GENERATED ... AS IDENTITY)
|
|
219
|
+
if (isIdentity === 'YES') {
|
|
220
|
+
return true;
|
|
253
221
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
switch (action.toUpperCase()) {
|
|
258
|
-
case 'CASCADE':
|
|
259
|
-
return 'CASCADE';
|
|
260
|
-
case 'SET NULL':
|
|
261
|
-
return 'SET NULL';
|
|
262
|
-
case 'RESTRICT':
|
|
263
|
-
return 'RESTRICT';
|
|
264
|
-
case 'NO ACTION':
|
|
265
|
-
return 'NO ACTION';
|
|
266
|
-
default:
|
|
267
|
-
return undefined;
|
|
222
|
+
// Serial/bigserial columns use nextval()
|
|
223
|
+
if (defaultValue?.includes('nextval(')) {
|
|
224
|
+
return true;
|
|
268
225
|
}
|
|
226
|
+
return false;
|
|
269
227
|
}
|
|
270
228
|
}
|
|
271
229
|
//# sourceMappingURL=postgresIntrospector.js.map
|