pg-migration-engine 0.1.0

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.
Files changed (104) hide show
  1. package/LICENSE +35 -0
  2. package/README.md +304 -0
  3. package/package.json +52 -0
  4. package/src/behavioral/behavioral-applier.js +374 -0
  5. package/src/behavioral/behavioral-extractor.js +266 -0
  6. package/src/behavioral/behavioral-puller.js +35 -0
  7. package/src/behavioral/index.js +4 -0
  8. package/src/behavioral/phase-sorter.js +24 -0
  9. package/src/constants.js +97 -0
  10. package/src/ddl-generator/alter-generator.js +1512 -0
  11. package/src/ddl-generator/comment-generator.js +95 -0
  12. package/src/ddl-generator/create-generator.js +1426 -0
  13. package/src/ddl-generator/drop-generator.js +194 -0
  14. package/src/ddl-generator/generator.js +78 -0
  15. package/src/ddl-generator/grant-generator.js +31 -0
  16. package/src/ddl-generator/index.js +3 -0
  17. package/src/ddl-generator/pg-version.js +15 -0
  18. package/src/ddl-generator/rename-generator.js +88 -0
  19. package/src/ddl-generator/safe-patterns.js +241 -0
  20. package/src/differ/change-classifier.js +192 -0
  21. package/src/differ/dependency-resolver.js +523 -0
  22. package/src/differ/index.js +12 -0
  23. package/src/differ/object-matcher.js +510 -0
  24. package/src/differ/property-differ.js +1134 -0
  25. package/src/differ/risk-tagger.js +561 -0
  26. package/src/differ/schema-differ.js +309 -0
  27. package/src/differ/utils/levenshtein.js +210 -0
  28. package/src/differ/utils/path-builder.js +198 -0
  29. package/src/differ/utils/type-compatibility.js +472 -0
  30. package/src/errors.js +147 -0
  31. package/src/executor/drift-detector.js +221 -0
  32. package/src/executor/index.js +7 -0
  33. package/src/executor/lock-manager.js +308 -0
  34. package/src/executor/migration-executor.js +1249 -0
  35. package/src/executor/progress-tracker.js +81 -0
  36. package/src/executor/recovery-manager.js +47 -0
  37. package/src/executor/snapshot-manager.js +22 -0
  38. package/src/executor/sql-splitter.js +120 -0
  39. package/src/executor/transaction-manager.js +288 -0
  40. package/src/index.js +483 -0
  41. package/src/introspection/index.js +4 -0
  42. package/src/introspection/introspector.js +250 -0
  43. package/src/introspection/queries/access-methods.js +29 -0
  44. package/src/introspection/queries/casts.js +38 -0
  45. package/src/introspection/queries/collations.js +51 -0
  46. package/src/introspection/queries/comments.js +66 -0
  47. package/src/introspection/queries/constraints.js +65 -0
  48. package/src/introspection/queries/conversions.js +39 -0
  49. package/src/introspection/queries/databases.js +43 -0
  50. package/src/introspection/queries/default-privileges.js +37 -0
  51. package/src/introspection/queries/event-triggers.js +43 -0
  52. package/src/introspection/queries/extensions.js +21 -0
  53. package/src/introspection/queries/foreign-data.js +136 -0
  54. package/src/introspection/queries/functions.js +75 -0
  55. package/src/introspection/queries/grants.js +38 -0
  56. package/src/introspection/queries/index.js +33 -0
  57. package/src/introspection/queries/indexes.js +99 -0
  58. package/src/introspection/queries/inheritance.js +24 -0
  59. package/src/introspection/queries/multiranges.js +37 -0
  60. package/src/introspection/queries/operators.js +180 -0
  61. package/src/introspection/queries/partitions.js +42 -0
  62. package/src/introspection/queries/pg18-19.js +43 -0
  63. package/src/introspection/queries/policies.js +35 -0
  64. package/src/introspection/queries/procedural-languages.js +36 -0
  65. package/src/introspection/queries/publications.js +114 -0
  66. package/src/introspection/queries/roles.js +66 -0
  67. package/src/introspection/queries/rules.js +49 -0
  68. package/src/introspection/queries/sequences.js +37 -0
  69. package/src/introspection/queries/statistics.js +74 -0
  70. package/src/introspection/queries/subscriptions.js +99 -0
  71. package/src/introspection/queries/tables.js +151 -0
  72. package/src/introspection/queries/tablespaces.js +36 -0
  73. package/src/introspection/queries/text-search.js +146 -0
  74. package/src/introspection/queries/triggers.js +61 -0
  75. package/src/introspection/queries/types.js +106 -0
  76. package/src/introspection/queries/views.js +146 -0
  77. package/src/introspection/translator.js +1283 -0
  78. package/src/introspection/version-detector.js +25 -0
  79. package/src/planner/backfill-planner.js +36 -0
  80. package/src/planner/dry-run.js +21 -0
  81. package/src/planner/index.js +6 -0
  82. package/src/planner/migration-planner.js +356 -0
  83. package/src/planner/smart-migrator.js +82 -0
  84. package/src/planner/step-sequencer.js +61 -0
  85. package/src/planner/type-registry.js +47 -0
  86. package/src/risk/compatibility-checker.js +29 -0
  87. package/src/risk/data-loss-checker.js +32 -0
  88. package/src/risk/destructive-checker.js +38 -0
  89. package/src/risk/index.js +6 -0
  90. package/src/risk/lock-analyzer.js +39 -0
  91. package/src/risk/recommendations.js +44 -0
  92. package/src/risk/risk-engine.js +25 -0
  93. package/src/storage/index.js +5 -0
  94. package/src/storage/memory-storage.js +87 -0
  95. package/src/storage/migration-table.js +423 -0
  96. package/src/storage/rollback-generator.js +344 -0
  97. package/src/types/changes.js +136 -0
  98. package/src/types/connection.js +17 -0
  99. package/src/types/execution.js +107 -0
  100. package/src/types/index.js +1 -0
  101. package/src/types/migration.js +67 -0
  102. package/src/types/risk.js +32 -0
  103. package/src/types/schema.d.ts +1004 -0
  104. package/src/types/schema.js +561 -0
@@ -0,0 +1,1004 @@
1
+ /**
2
+ * SchemaSnapshot - Complete representation of a PostgreSQL database schema
3
+ * @typedef {Object} SchemaSnapshot
4
+ * @property {{numeric:number,major:number,string:string}} version
5
+ * @property {string} timestamp
6
+ * @property {string} checksum
7
+ * @property {DatabaseInfo} [database]
8
+ * @property {Record<string, SchemaInfo>} schemas
9
+ * @property {Record<string, TableInfo>} tables
10
+ * @property {Record<string, ViewInfo>} views
11
+ * @property {Record<string, MaterializedViewInfo>} materializedViews
12
+ * @property {Record<string, IndexInfo>} indexes
13
+ * @property {Record<string, FunctionInfo>} functions
14
+ * @property {Record<string, ProcedureInfo>} procedures
15
+ * @property {Record<string, AggregateInfo>} aggregates
16
+ * @property {Record<string, TriggerInfo>} triggers
17
+ * @property {Record<string, EventTriggerInfo>} eventTriggers
18
+ * @property {Record<string, TypeInfo>} types
19
+ * @property {Record<string, SequenceInfo>} sequences
20
+ * @property {Record<string, ExtensionInfo>} extensions
21
+ * @property {Record<string, PolicyInfo>} policies
22
+ * @property {Record<string, ConstraintInfo>} constraints
23
+ * @property {Record<string, string>} comments
24
+ * @property {GrantInfo[]} grants
25
+ * @property {Record<string, StatisticsInfo>} statistics
26
+ * @property {Record<string, CollationInfo>} collations
27
+ * @property {Record<string, ConversionInfo>} conversions
28
+ * @property {Record<string, OperatorInfo>} operators
29
+ * @property {Record<string, OperatorClassInfo>} operatorClasses
30
+ * @property {Record<string, OperatorFamilyInfo>} operatorFamilies
31
+ * @property {Record<string, TextSearchConfigInfo>} textSearchConfigs
32
+ * @property {Record<string, TextSearchDictInfo>} textSearchDictionaries
33
+ * @property {Record<string, TextSearchParserInfo>} textSearchParsers
34
+ * @property {Record<string, TextSearchTemplateInfo>} textSearchTemplates
35
+ * @property {Record<string, ForeignDataWrapperInfo>} foreignDataWrappers
36
+ * @property {Record<string, ForeignServerInfo>} foreignServers
37
+ * @property {Record<string, UserMappingInfo>} userMappings
38
+ * @property {Record<string, CastInfo>} casts
39
+ * @property {Record<string, RuleInfo>} rules
40
+ * @property {Record<string, RoleInfo>} roles
41
+ * @property {Record<string, TablespaceInfo>} tablespaces
42
+ * @property {Record<string, AccessMethodInfo>} accessMethods
43
+ * @property {Record<string, LanguageInfo>} languages
44
+ * @property {Record<string, DefaultPrivilegeInfo>} defaultPrivileges
45
+ * @property {Record<string, DatabaseInfo>} databases
46
+ * @property {Record<string, PublicationInfo>} publications
47
+ * @property {Record<string, SubscriptionInfo>} subscriptions
48
+ */
49
+ export type SchemaSnapshot = {
50
+ version: {
51
+ numeric: number;
52
+ major: number;
53
+ string: string;
54
+ };
55
+ timestamp: string;
56
+ checksum: string;
57
+ database?: DatabaseInfo;
58
+ schemas: Record<string, SchemaInfo>;
59
+ tables: Record<string, TableInfo>;
60
+ views: Record<string, ViewInfo>;
61
+ materializedViews: Record<string, MaterializedViewInfo>;
62
+ indexes: Record<string, IndexInfo>;
63
+ functions: Record<string, FunctionInfo>;
64
+ procedures: Record<string, ProcedureInfo>;
65
+ aggregates: Record<string, AggregateInfo>;
66
+ triggers: Record<string, TriggerInfo>;
67
+ eventTriggers: Record<string, EventTriggerInfo>;
68
+ types: Record<string, TypeInfo>;
69
+ sequences: Record<string, SequenceInfo>;
70
+ extensions: Record<string, ExtensionInfo>;
71
+ policies: Record<string, PolicyInfo>;
72
+ constraints: Record<string, ConstraintInfo>;
73
+ comments: Record<string, string>;
74
+ grants: GrantInfo[];
75
+ statistics: Record<string, StatisticsInfo>;
76
+ collations: Record<string, CollationInfo>;
77
+ conversions: Record<string, ConversionInfo>;
78
+ operators: Record<string, OperatorInfo>;
79
+ operatorClasses: Record<string, OperatorClassInfo>;
80
+ operatorFamilies: Record<string, OperatorFamilyInfo>;
81
+ textSearchConfigs: Record<string, TextSearchConfigInfo>;
82
+ textSearchDictionaries: Record<string, TextSearchDictInfo>;
83
+ textSearchParsers: Record<string, TextSearchParserInfo>;
84
+ textSearchTemplates: Record<string, TextSearchTemplateInfo>;
85
+ foreignDataWrappers: Record<string, ForeignDataWrapperInfo>;
86
+ foreignServers: Record<string, ForeignServerInfo>;
87
+ userMappings: Record<string, UserMappingInfo>;
88
+ casts: Record<string, CastInfo>;
89
+ rules: Record<string, RuleInfo>;
90
+ roles: Record<string, RoleInfo>;
91
+ tablespaces: Record<string, TablespaceInfo>;
92
+ accessMethods: Record<string, AccessMethodInfo>;
93
+ languages: Record<string, LanguageInfo>;
94
+ defaultPrivileges: Record<string, DefaultPrivilegeInfo>;
95
+ databases: Record<string, DatabaseInfo>;
96
+ publications: Record<string, PublicationInfo>;
97
+ subscriptions: Record<string, SubscriptionInfo>;
98
+ };
99
+ export type SchemaInfo = {
100
+ name: string;
101
+ owner: string;
102
+ };
103
+ export type DatabaseInfo = {
104
+ name: string;
105
+ owner: string;
106
+ encoding: string;
107
+ collate: string;
108
+ ctype: string;
109
+ isTemplate?: boolean;
110
+ allowConn?: boolean;
111
+ };
112
+ export type TableInfo = {
113
+ schema: string;
114
+ name: string;
115
+ owner: string;
116
+ isTemporary: boolean;
117
+ isUnlogged: boolean;
118
+ isPartitioned: boolean;
119
+ isPartition: boolean;
120
+ isForeignTable: boolean;
121
+ partitionStrategy?: 'RANGE' | 'LIST' | 'HASH';
122
+ partitionColumns?: string[];
123
+ partitionParent?: string;
124
+ partitionBound?: string;
125
+ partitionKeyDef?: string;
126
+ inheritsFrom?: string[];
127
+ ofType?: string;
128
+ tablespace?: string;
129
+ storageParameters?: Record<string, string | number>;
130
+ replicaIdentity?: 'DEFAULT' | 'NOTHING' | 'FULL' | 'INDEX';
131
+ hasOids?: boolean;
132
+ comment?: string;
133
+ privileges?: Object[];
134
+ rlsEnabled: boolean;
135
+ rlsForced: boolean;
136
+ columns: ColumnInfo[];
137
+ constraints: string[];
138
+ indexes: string[];
139
+ triggers: string[];
140
+ policies: string[];
141
+ foreignServer?: string;
142
+ foreignOptions?: Object;
143
+ };
144
+ export type ColumnInfo = {
145
+ name: string;
146
+ dataType: string;
147
+ ordinalPosition: number;
148
+ isNullable: boolean;
149
+ defaultValue?: string;
150
+ isGenerated: boolean;
151
+ generatedExpression?: string;
152
+ generatedStorage?: 'STORED' | 'VIRTUAL';
153
+ isIdentity: boolean;
154
+ identityMode?: 'ALWAYS' | 'BY_DEFAULT';
155
+ identityOptions?: SequenceOptions;
156
+ collation?: string;
157
+ storage?: 'PLAIN' | 'EXTERNAL' | 'EXTENDED' | 'MAIN' | 'DEFAULT';
158
+ statistics?: number;
159
+ compression?: string;
160
+ comment?: string;
161
+ foreignOptions?: Object;
162
+ };
163
+ export type ConstraintInfo = {
164
+ schema: string;
165
+ name: string;
166
+ table: string;
167
+ type: 'PRIMARY_KEY' | 'UNIQUE' | 'FOREIGN_KEY' | 'CHECK' | 'EXCLUSION' | 'NOT_NULL';
168
+ deferrable: boolean;
169
+ initiallyDeferred: boolean;
170
+ isValidated: boolean;
171
+ enforced: boolean;
172
+ noInherit: boolean;
173
+ definition: string;
174
+ columns?: string[];
175
+ referencedTable?: string;
176
+ referencedColumns?: string[];
177
+ matchType?: 'FULL' | 'PARTIAL' | 'SIMPLE';
178
+ onDelete?: string;
179
+ onUpdate?: string;
180
+ periodColumn?: string;
181
+ withoutOverlaps?: string;
182
+ nullsNotDistinct?: boolean;
183
+ checkExpression?: string;
184
+ excludeElements?: Array<{
185
+ column: string;
186
+ operator: string;
187
+ }>;
188
+ excludeMethod?: string;
189
+ index?: string;
190
+ };
191
+ export type IndexInfo = {
192
+ schema: string;
193
+ name: string;
194
+ table: string;
195
+ isUnique: boolean;
196
+ isPrimary: boolean;
197
+ isConcurrent: boolean;
198
+ method: string;
199
+ columns: IndexColumnInfo[];
200
+ includeColumns?: string[];
201
+ whereClause?: string;
202
+ storageParameters?: Record<string, string | number>;
203
+ tablespace?: string;
204
+ nullsNotDistinct?: boolean;
205
+ isPartitioned?: boolean;
206
+ comment?: string;
207
+ };
208
+ export type IndexColumnInfo = {
209
+ expression: string;
210
+ collation?: string;
211
+ opclass?: string;
212
+ direction?: 'ASC' | 'DESC';
213
+ nullsOrder?: 'FIRST' | 'LAST';
214
+ };
215
+ export type FunctionInfo = {
216
+ schema: string;
217
+ name: string;
218
+ argumentTypes: string[];
219
+ returnType: string;
220
+ language: string;
221
+ source: string;
222
+ volatility: 'IMMUTABLE' | 'STABLE' | 'VOLATILE';
223
+ isStrict: boolean;
224
+ security: 'INVOKER' | 'DEFINER';
225
+ parallel: 'SAFE' | 'UNSAFE' | 'RESTRICTED';
226
+ isLeakproof: boolean;
227
+ cost: number;
228
+ rows: number;
229
+ kind: 'FUNCTION' | 'PROCEDURE' | 'AGGREGATE' | 'WINDOW';
230
+ comment?: string;
231
+ };
232
+ export type ProcedureInfo = {
233
+ schema: string;
234
+ name: string;
235
+ argumentTypes: string[];
236
+ language: string;
237
+ source: string;
238
+ security: 'INVOKER' | 'DEFINER';
239
+ parallel: 'SAFE' | 'UNSAFE' | 'RESTRICTED';
240
+ };
241
+ export type AggregateInfo = {
242
+ schema: string;
243
+ name: string;
244
+ argumentTypes: string[];
245
+ returnType: string;
246
+ language: string;
247
+ source: string;
248
+ };
249
+ export type ViewInfo = {
250
+ schema: string;
251
+ name: string;
252
+ definition: string;
253
+ owner: string;
254
+ checkOption?: 'LOCAL' | 'CASCADED';
255
+ isRecursive: boolean;
256
+ columns?: ColumnInfo[];
257
+ comment?: string;
258
+ };
259
+ export type MaterializedViewInfo = {
260
+ schema: string;
261
+ name: string;
262
+ definition: string;
263
+ owner: string;
264
+ tablespace?: string;
265
+ storageParameters?: Record<string, string | number>;
266
+ withData: boolean;
267
+ comment?: string;
268
+ };
269
+ export type TypeInfo = {
270
+ schema: string;
271
+ name: string;
272
+ kind: 'ENUM' | 'COMPOSITE' | 'DOMAIN' | 'RANGE' | 'BASE' | 'SHELL' | 'MULTIRANGE';
273
+ rangeType?: string;
274
+ enumValues?: string[];
275
+ attributes?: Array<{
276
+ name: string;
277
+ type: string;
278
+ }>;
279
+ baseType?: string;
280
+ notNull?: boolean;
281
+ defaultValue?: string;
282
+ checkConstraint?: string;
283
+ subtype?: string;
284
+ inputFunction?: string;
285
+ outputFunction?: string;
286
+ owner: string;
287
+ comment?: string;
288
+ };
289
+ export type SequenceInfo = {
290
+ schema: string;
291
+ name: string;
292
+ dataType: string;
293
+ startValue?: number;
294
+ increment?: number;
295
+ minValue?: number;
296
+ maxValue?: number;
297
+ cache?: number;
298
+ cycle: boolean;
299
+ ownedBy?: string;
300
+ owner: string;
301
+ };
302
+ export type TriggerInfo = {
303
+ schema: string;
304
+ name: string;
305
+ table: string;
306
+ timing: 'BEFORE' | 'AFTER' | 'INSTEAD OF';
307
+ events: Array<'INSERT' | 'UPDATE' | 'DELETE' | 'TRUNCATE'>;
308
+ isForEachRow: boolean;
309
+ whenCondition?: string;
310
+ functionCall: string;
311
+ enabled: 'ENABLED' | 'DISABLED' | 'REPLICA' | 'ALWAYS';
312
+ comment?: string;
313
+ };
314
+ export type EventTriggerInfo = {
315
+ name: string;
316
+ event: string;
317
+ function: string;
318
+ enabled: 'ENABLED' | 'DISABLED' | 'REPLICA' | 'ALWAYS';
319
+ tags: string[];
320
+ owner: string;
321
+ };
322
+ export type ExtensionInfo = {
323
+ name: string;
324
+ schema: string;
325
+ version: string;
326
+ isAvailable: boolean;
327
+ };
328
+ export type PolicyInfo = {
329
+ schema: string;
330
+ name: string;
331
+ table: string;
332
+ command: 'ALL' | 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE';
333
+ isPermissive: boolean;
334
+ roles: string[];
335
+ usingExpression?: string;
336
+ withCheckExpression?: string;
337
+ };
338
+ export type GrantInfo = {
339
+ schema: string;
340
+ object: string;
341
+ objectType: string;
342
+ privilege: string;
343
+ grantee: string;
344
+ grantor: string;
345
+ isGrantable: boolean;
346
+ column?: string;
347
+ };
348
+ export type SequenceOptions = {
349
+ startWith?: number;
350
+ incrementBy?: number;
351
+ minValue?: number | 'NO_MINVALUE';
352
+ maxValue?: number | 'NO_MAXVALUE';
353
+ cache?: number;
354
+ cycle?: boolean;
355
+ ownedBy?: string;
356
+ };
357
+ export type StatisticsInfo = {
358
+ schema: string;
359
+ name: string;
360
+ table?: string;
361
+ kinds: Array<string>;
362
+ columns: string[];
363
+ definition?: string;
364
+ owner: string;
365
+ };
366
+ export type CollationInfo = {
367
+ schema: string;
368
+ name: string;
369
+ provider: string;
370
+ locale?: string;
371
+ encoding?: number;
372
+ isDeterministic: boolean;
373
+ owner: string;
374
+ };
375
+ export type ConversionInfo = {
376
+ schema: string;
377
+ name: string;
378
+ proc: string;
379
+ isDefault: boolean;
380
+ owner: string;
381
+ };
382
+ export type OperatorInfo = {
383
+ schema: string;
384
+ name: string;
385
+ leftType?: string;
386
+ rightType?: string;
387
+ resultType?: string;
388
+ proc: string;
389
+ canHash: boolean;
390
+ canMerge: boolean;
391
+ commutator?: string;
392
+ negator?: string;
393
+ owner: string;
394
+ };
395
+ export type OperatorClassInfo = {
396
+ schema: string;
397
+ name: string;
398
+ family: string;
399
+ inputType: string;
400
+ isDefault: boolean;
401
+ accessMethod: string;
402
+ owner: string;
403
+ };
404
+ export type OperatorFamilyInfo = {
405
+ schema: string;
406
+ name: string;
407
+ accessMethod: string;
408
+ owner: string;
409
+ };
410
+ export type TextSearchConfigInfo = {
411
+ schema: string;
412
+ name: string;
413
+ parser: string;
414
+ owner: string;
415
+ };
416
+ export type TextSearchDictInfo = {
417
+ schema: string;
418
+ name: string;
419
+ template: string;
420
+ options?: Object;
421
+ owner: string;
422
+ };
423
+ export type TextSearchParserInfo = {
424
+ schema: string;
425
+ name: string;
426
+ start: string;
427
+ getToken: string;
428
+ end: string;
429
+ headline?: string;
430
+ owner: string;
431
+ };
432
+ export type TextSearchTemplateInfo = {
433
+ schema: string;
434
+ name: string;
435
+ init?: string;
436
+ lexize: string;
437
+ owner: string;
438
+ };
439
+ export type ForeignDataWrapperInfo = {
440
+ name: string;
441
+ handler?: string;
442
+ validator?: string;
443
+ options?: Object;
444
+ owner: string;
445
+ };
446
+ export type ForeignServerInfo = {
447
+ name: string;
448
+ fdw: string;
449
+ type?: string;
450
+ options?: Object;
451
+ owner: string;
452
+ };
453
+ export type UserMappingInfo = {
454
+ user: string;
455
+ server: string;
456
+ options?: Object;
457
+ };
458
+ export type CastInfo = {
459
+ sourceType: string;
460
+ targetType: string;
461
+ function?: string;
462
+ context: 'EXPLICIT' | 'ASSIGNMENT' | 'IMPLICIT';
463
+ method: 'FUNCTION' | 'INOUT' | 'BINARY';
464
+ };
465
+ export type RuleInfo = {
466
+ schema: string;
467
+ name: string;
468
+ table: string;
469
+ event: string;
470
+ isInstead: boolean;
471
+ isEnabled: boolean;
472
+ definition?: string;
473
+ qual?: string;
474
+ };
475
+ export type RoleInfo = {
476
+ name: string;
477
+ isSuperuser: boolean;
478
+ canCreateRole: boolean;
479
+ canCreateDB: boolean;
480
+ canLogin: boolean;
481
+ inherit: boolean;
482
+ memberships: Array<{
483
+ member: string;
484
+ admin_option: boolean;
485
+ }>;
486
+ comment?: string;
487
+ };
488
+ export type TablespaceInfo = {
489
+ name: string;
490
+ owner: string;
491
+ location?: string;
492
+ isDefault: boolean;
493
+ acl?: string;
494
+ options?: Object;
495
+ };
496
+ export type AccessMethodInfo = {
497
+ name: string;
498
+ type: 'TABLE' | 'INDEX';
499
+ handler?: string;
500
+ };
501
+ export type LanguageInfo = {
502
+ name: string;
503
+ isTrusted: boolean;
504
+ handler?: string;
505
+ inline?: string;
506
+ validator?: string;
507
+ owner: string;
508
+ };
509
+ export type DefaultPrivilegeInfo = {
510
+ role: string;
511
+ schema?: string;
512
+ objectType: string;
513
+ acl: string;
514
+ };
515
+ export type PublicationInfo = {
516
+ name: string;
517
+ owner: string;
518
+ allTables: boolean;
519
+ insert: boolean;
520
+ update: boolean;
521
+ delete: boolean;
522
+ truncate: boolean;
523
+ tables: string[];
524
+ schemas: string[];
525
+ };
526
+ export type SubscriptionInfo = {
527
+ name: string;
528
+ conninfo: string;
529
+ slotName?: string;
530
+ publications: string[];
531
+ enabled: boolean;
532
+ syncCommit?: boolean;
533
+ owner: string;
534
+ };
535
+ /**
536
+ * @typedef {Object} SchemaInfo
537
+ * @property {string} name
538
+ * @property {string} owner
539
+ */
540
+ /**
541
+ * @typedef {Object} DatabaseInfo
542
+ * @property {string} name
543
+ * @property {string} owner
544
+ * @property {string} encoding
545
+ * @property {string} collate
546
+ * @property {string} ctype
547
+ * @property {boolean} [isTemplate]
548
+ * @property {boolean} [allowConn]
549
+ */
550
+ /**
551
+ * @typedef {Object} TableInfo
552
+ * @property {string} schema
553
+ * @property {string} name
554
+ * @property {string} owner
555
+ * @property {boolean} isTemporary
556
+ * @property {boolean} isUnlogged
557
+ * @property {boolean} isPartitioned
558
+ * @property {boolean} isPartition
559
+ * @property {boolean} isForeignTable
560
+ * @property {'RANGE'|'LIST'|'HASH'} [partitionStrategy]
561
+ * @property {string[]} [partitionColumns]
562
+ * @property {string} [partitionParent]
563
+ * @property {string} [partitionBound]
564
+ * @property {string} [partitionKeyDef]
565
+ * @property {string[]} [inheritsFrom]
566
+ * @property {string} [ofType]
567
+ * @property {string} [tablespace]
568
+ * @property {Record<string, string|number>} [storageParameters]
569
+ * @property {'DEFAULT'|'NOTHING'|'FULL'|'INDEX'} [replicaIdentity]
570
+ * @property {boolean} [hasOids]
571
+ * @property {string} [comment]
572
+ * @property {Object[]} [privileges]
573
+ * @property {boolean} rlsEnabled
574
+ * @property {boolean} rlsForced
575
+ * @property {ColumnInfo[]} columns
576
+ * @property {string[]} constraints
577
+ * @property {string[]} indexes
578
+ * @property {string[]} triggers
579
+ * @property {string[]} policies
580
+ * @property {string} [foreignServer]
581
+ * @property {Object} [foreignOptions]
582
+ */
583
+ /**
584
+ * @typedef {Object} ColumnInfo
585
+ * @property {string} name
586
+ * @property {string} dataType
587
+ * @property {number} ordinalPosition
588
+ * @property {boolean} isNullable
589
+ * @property {string} [defaultValue]
590
+ * @property {boolean} isGenerated
591
+ * @property {string} [generatedExpression]
592
+ * @property {'STORED'|'VIRTUAL'} [generatedStorage]
593
+ * @property {boolean} isIdentity
594
+ * @property {'ALWAYS'|'BY_DEFAULT'} [identityMode]
595
+ * @property {SequenceOptions} [identityOptions]
596
+ * @property {string} [collation]
597
+ * @property {'PLAIN'|'EXTERNAL'|'EXTENDED'|'MAIN'|'DEFAULT'} [storage]
598
+ * @property {number} [statistics]
599
+ * @property {string} [compression]
600
+ * @property {string} [comment]
601
+ * @property {Object} [foreignOptions]
602
+ */
603
+ /**
604
+ * @typedef {Object} ConstraintInfo
605
+ * @property {string} schema
606
+ * @property {string} name
607
+ * @property {string} table
608
+ * @property {'PRIMARY_KEY'|'UNIQUE'|'FOREIGN_KEY'|'CHECK'|'EXCLUSION'|'NOT_NULL'} type
609
+ * @property {boolean} deferrable
610
+ * @property {boolean} initiallyDeferred
611
+ * @property {boolean} isValidated
612
+ * @property {boolean} enforced
613
+ * @property {boolean} noInherit
614
+ * @property {string} definition
615
+ * @property {string[]} [columns]
616
+ * @property {string} [referencedTable]
617
+ * @property {string[]} [referencedColumns]
618
+ * @property {'FULL'|'PARTIAL'|'SIMPLE'} [matchType]
619
+ * @property {string} [onDelete]
620
+ * @property {string} [onUpdate]
621
+ * @property {string} [periodColumn]
622
+ * @property {string} [withoutOverlaps]
623
+ * @property {boolean} [nullsNotDistinct]
624
+ * @property {string} [checkExpression]
625
+ * @property {Array<{column:string,operator:string}>} [excludeElements]
626
+ * @property {string} [excludeMethod]
627
+ * @property {string} [index]
628
+ */
629
+ /**
630
+ * @typedef {Object} IndexInfo
631
+ * @property {string} schema
632
+ * @property {string} name
633
+ * @property {string} table
634
+ * @property {boolean} isUnique
635
+ * @property {boolean} isPrimary
636
+ * @property {boolean} isConcurrent
637
+ * @property {string} method
638
+ * @property {IndexColumnInfo[]} columns
639
+ * @property {string[]} [includeColumns]
640
+ * @property {string} [whereClause]
641
+ * @property {Record<string, string|number>} [storageParameters]
642
+ * @property {string} [tablespace]
643
+ * @property {boolean} [nullsNotDistinct]
644
+ * @property {boolean} [isPartitioned]
645
+ * @property {string} [comment]
646
+ */
647
+ /**
648
+ * @typedef {Object} IndexColumnInfo
649
+ * @property {string} expression
650
+ * @property {string} [collation]
651
+ * @property {string} [opclass]
652
+ * @property {'ASC'|'DESC'} [direction]
653
+ * @property {'FIRST'|'LAST'} [nullsOrder]
654
+ */
655
+ /**
656
+ * @typedef {Object} FunctionInfo
657
+ * @property {string} schema
658
+ * @property {string} name
659
+ * @property {string[]} argumentTypes
660
+ * @property {string} returnType
661
+ * @property {string} language
662
+ * @property {string} source
663
+ * @property {'IMMUTABLE'|'STABLE'|'VOLATILE'} volatility
664
+ * @property {boolean} isStrict
665
+ * @property {'INVOKER'|'DEFINER'} security
666
+ * @property {'SAFE'|'UNSAFE'|'RESTRICTED'} parallel
667
+ * @property {boolean} isLeakproof
668
+ * @property {number} cost
669
+ * @property {number} rows
670
+ * @property {'FUNCTION'|'PROCEDURE'|'AGGREGATE'|'WINDOW'} kind
671
+ * @property {string} [comment]
672
+ */
673
+ /**
674
+ * @typedef {Object} ProcedureInfo
675
+ * @property {string} schema
676
+ * @property {string} name
677
+ * @property {string[]} argumentTypes
678
+ * @property {string} language
679
+ * @property {string} source
680
+ * @property {'INVOKER'|'DEFINER'} security
681
+ * @property {'SAFE'|'UNSAFE'|'RESTRICTED'} parallel
682
+ */
683
+ /**
684
+ * @typedef {Object} AggregateInfo
685
+ * @property {string} schema
686
+ * @property {string} name
687
+ * @property {string[]} argumentTypes
688
+ * @property {string} returnType
689
+ * @property {string} language
690
+ * @property {string} source
691
+ */
692
+ /**
693
+ * @typedef {Object} ViewInfo
694
+ * @property {string} schema
695
+ * @property {string} name
696
+ * @property {string} definition
697
+ * @property {string} owner
698
+ * @property {'LOCAL'|'CASCADED'} [checkOption]
699
+ * @property {boolean} isRecursive
700
+ * @property {ColumnInfo[]} [columns]
701
+ * @property {string} [comment]
702
+ */
703
+ /**
704
+ * @typedef {Object} MaterializedViewInfo
705
+ * @property {string} schema
706
+ * @property {string} name
707
+ * @property {string} definition
708
+ * @property {string} owner
709
+ * @property {string} [tablespace]
710
+ * @property {Record<string, string|number>} [storageParameters]
711
+ * @property {boolean} withData
712
+ * @property {string} [comment]
713
+ */
714
+ /**
715
+ * @typedef {Object} TypeInfo
716
+ * @property {string} schema
717
+ * @property {string} name
718
+ * @property {'ENUM'|'COMPOSITE'|'DOMAIN'|'RANGE'|'BASE'|'SHELL'|'MULTIRANGE'} kind
719
+ * @property {string} [rangeType]
720
+ * @property {string[]} [enumValues]
721
+ * @property {Array<{name:string,type:string}>} [attributes]
722
+ * @property {string} [baseType]
723
+ * @property {boolean} [notNull]
724
+ * @property {string} [defaultValue]
725
+ * @property {string} [checkConstraint]
726
+ * @property {string} [subtype]
727
+ * @property {string} [inputFunction]
728
+ * @property {string} [outputFunction]
729
+ * @property {string} owner
730
+ * @property {string} [comment]
731
+ */
732
+ /**
733
+ * @typedef {Object} SequenceInfo
734
+ * @property {string} schema
735
+ * @property {string} name
736
+ * @property {string} dataType
737
+ * @property {number} [startValue]
738
+ * @property {number} [increment]
739
+ * @property {number} [minValue]
740
+ * @property {number} [maxValue]
741
+ * @property {number} [cache]
742
+ * @property {boolean} cycle
743
+ * @property {string} [ownedBy]
744
+ * @property {string} owner
745
+ */
746
+ /**
747
+ * @typedef {Object} TriggerInfo
748
+ * @property {string} schema
749
+ * @property {string} name
750
+ * @property {string} table
751
+ * @property {'BEFORE'|'AFTER'|'INSTEAD OF'} timing
752
+ * @property {Array<'INSERT'|'UPDATE'|'DELETE'|'TRUNCATE'>} events
753
+ * @property {boolean} isForEachRow
754
+ * @property {string} [whenCondition]
755
+ * @property {string} functionCall
756
+ * @property {'ENABLED'|'DISABLED'|'REPLICA'|'ALWAYS'} enabled
757
+ * @property {string} [comment]
758
+ */
759
+ /**
760
+ * @typedef {Object} EventTriggerInfo
761
+ * @property {string} name
762
+ * @property {string} event
763
+ * @property {string} function
764
+ * @property {'ENABLED'|'DISABLED'|'REPLICA'|'ALWAYS'} enabled
765
+ * @property {string[]} tags
766
+ * @property {string} owner
767
+ */
768
+ /**
769
+ * @typedef {Object} ExtensionInfo
770
+ * @property {string} name
771
+ * @property {string} schema
772
+ * @property {string} version
773
+ * @property {boolean} isAvailable
774
+ */
775
+ /**
776
+ * @typedef {Object} PolicyInfo
777
+ * @property {string} schema
778
+ * @property {string} name
779
+ * @property {string} table
780
+ * @property {'ALL'|'SELECT'|'INSERT'|'UPDATE'|'DELETE'} command
781
+ * @property {boolean} isPermissive
782
+ * @property {string[]} roles
783
+ * @property {string} [usingExpression]
784
+ * @property {string} [withCheckExpression]
785
+ */
786
+ /**
787
+ * @typedef {Object} GrantInfo
788
+ * @property {string} schema
789
+ * @property {string} object
790
+ * @property {string} objectType
791
+ * @property {string} privilege
792
+ * @property {string} grantee
793
+ * @property {string} grantor
794
+ * @property {boolean} isGrantable
795
+ * @property {string} [column]
796
+ */
797
+ /**
798
+ * @typedef {Object} SequenceOptions
799
+ * @property {number} [startWith]
800
+ * @property {number} [incrementBy]
801
+ * @property {number|'NO_MINVALUE'} [minValue]
802
+ * @property {number|'NO_MAXVALUE'} [maxValue]
803
+ * @property {number} [cache]
804
+ * @property {boolean} [cycle]
805
+ * @property {string} [ownedBy]
806
+ */
807
+ /**
808
+ * @typedef {Object} StatisticsInfo
809
+ * @property {string} schema
810
+ * @property {string} name
811
+ * @property {string} [table]
812
+ * @property {Array<string>} kinds
813
+ * @property {string[]} columns
814
+ * @property {string} [definition]
815
+ * @property {string} owner
816
+ */
817
+ /**
818
+ * @typedef {Object} CollationInfo
819
+ * @property {string} schema
820
+ * @property {string} name
821
+ * @property {string} provider
822
+ * @property {string} [locale]
823
+ * @property {number} [encoding]
824
+ * @property {boolean} isDeterministic
825
+ * @property {string} owner
826
+ */
827
+ /**
828
+ * @typedef {Object} ConversionInfo
829
+ * @property {string} schema
830
+ * @property {string} name
831
+ * @property {string} proc
832
+ * @property {boolean} isDefault
833
+ * @property {string} owner
834
+ */
835
+ /**
836
+ * @typedef {Object} OperatorInfo
837
+ * @property {string} schema
838
+ * @property {string} name
839
+ * @property {string} [leftType]
840
+ * @property {string} [rightType]
841
+ * @property {string} [resultType]
842
+ * @property {string} proc
843
+ * @property {boolean} canHash
844
+ * @property {boolean} canMerge
845
+ * @property {string} [commutator]
846
+ * @property {string} [negator]
847
+ * @property {string} owner
848
+ */
849
+ /**
850
+ * @typedef {Object} OperatorClassInfo
851
+ * @property {string} schema
852
+ * @property {string} name
853
+ * @property {string} family
854
+ * @property {string} inputType
855
+ * @property {boolean} isDefault
856
+ * @property {string} accessMethod
857
+ * @property {string} owner
858
+ */
859
+ /**
860
+ * @typedef {Object} OperatorFamilyInfo
861
+ * @property {string} schema
862
+ * @property {string} name
863
+ * @property {string} accessMethod
864
+ * @property {string} owner
865
+ */
866
+ /**
867
+ * @typedef {Object} TextSearchConfigInfo
868
+ * @property {string} schema
869
+ * @property {string} name
870
+ * @property {string} parser
871
+ * @property {string} owner
872
+ */
873
+ /**
874
+ * @typedef {Object} TextSearchDictInfo
875
+ * @property {string} schema
876
+ * @property {string} name
877
+ * @property {string} template
878
+ * @property {Object} [options]
879
+ * @property {string} owner
880
+ */
881
+ /**
882
+ * @typedef {Object} TextSearchParserInfo
883
+ * @property {string} schema
884
+ * @property {string} name
885
+ * @property {string} start
886
+ * @property {string} getToken
887
+ * @property {string} end
888
+ * @property {string} [headline]
889
+ * @property {string} owner
890
+ */
891
+ /**
892
+ * @typedef {Object} TextSearchTemplateInfo
893
+ * @property {string} schema
894
+ * @property {string} name
895
+ * @property {string} [init]
896
+ * @property {string} lexize
897
+ * @property {string} owner
898
+ */
899
+ /**
900
+ * @typedef {Object} ForeignDataWrapperInfo
901
+ * @property {string} name
902
+ * @property {string} [handler]
903
+ * @property {string} [validator]
904
+ * @property {Object} [options]
905
+ * @property {string} owner
906
+ */
907
+ /**
908
+ * @typedef {Object} ForeignServerInfo
909
+ * @property {string} name
910
+ * @property {string} fdw
911
+ * @property {string} [type]
912
+ * @property {Object} [options]
913
+ * @property {string} owner
914
+ */
915
+ /**
916
+ * @typedef {Object} UserMappingInfo
917
+ * @property {string} user
918
+ * @property {string} server
919
+ * @property {Object} [options]
920
+ */
921
+ /**
922
+ * @typedef {Object} CastInfo
923
+ * @property {string} sourceType
924
+ * @property {string} targetType
925
+ * @property {string} [function]
926
+ * @property {'EXPLICIT'|'ASSIGNMENT'|'IMPLICIT'} context
927
+ * @property {'FUNCTION'|'INOUT'|'BINARY'} method
928
+ */
929
+ /**
930
+ * @typedef {Object} RuleInfo
931
+ * @property {string} schema
932
+ * @property {string} name
933
+ * @property {string} table
934
+ * @property {string} event
935
+ * @property {boolean} isInstead
936
+ * @property {boolean} isEnabled
937
+ * @property {string} [definition]
938
+ * @property {string} [qual]
939
+ */
940
+ /**
941
+ * @typedef {Object} RoleInfo
942
+ * @property {string} name
943
+ * @property {boolean} isSuperuser
944
+ * @property {boolean} canCreateRole
945
+ * @property {boolean} canCreateDB
946
+ * @property {boolean} canLogin
947
+ * @property {boolean} inherit
948
+ * @property {Array<{member:string,admin_option:boolean}>} memberships
949
+ * @property {string} [comment]
950
+ */
951
+ /**
952
+ * @typedef {Object} TablespaceInfo
953
+ * @property {string} name
954
+ * @property {string} owner
955
+ * @property {string} [location]
956
+ * @property {boolean} isDefault
957
+ * @property {string} [acl]
958
+ * @property {Object} [options]
959
+ */
960
+ /**
961
+ * @typedef {Object} AccessMethodInfo
962
+ * @property {string} name
963
+ * @property {'TABLE'|'INDEX'} type
964
+ * @property {string} [handler]
965
+ */
966
+ /**
967
+ * @typedef {Object} LanguageInfo
968
+ * @property {string} name
969
+ * @property {boolean} isTrusted
970
+ * @property {string} [handler]
971
+ * @property {string} [inline]
972
+ * @property {string} [validator]
973
+ * @property {string} owner
974
+ */
975
+ /**
976
+ * @typedef {Object} DefaultPrivilegeInfo
977
+ * @property {string} role
978
+ * @property {string} [schema]
979
+ * @property {string} objectType
980
+ * @property {string} acl
981
+ */
982
+ /**
983
+ * @typedef {Object} PublicationInfo
984
+ * @property {string} name
985
+ * @property {string} owner
986
+ * @property {boolean} allTables
987
+ * @property {boolean} insert
988
+ * @property {boolean} update
989
+ * @property {boolean} delete
990
+ * @property {boolean} truncate
991
+ * @property {string[]} tables
992
+ * @property {string[]} schemas
993
+ */
994
+ /**
995
+ * @typedef {Object} SubscriptionInfo
996
+ * @property {string} name
997
+ * @property {string} conninfo
998
+ * @property {string} [slotName]
999
+ * @property {string[]} publications
1000
+ * @property {boolean} enabled
1001
+ * @property {boolean} [syncCommit]
1002
+ * @property {string} owner
1003
+ */
1004
+ export {};