@pgpmjs/core 4.10.1 → 4.12.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.
- package/esm/export/export-meta.js +635 -12
- package/export/export-meta.js +635 -12
- package/package.json +3 -3
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Parser } from 'csv-to-pg';
|
|
2
2
|
import { getPgPool } from 'pg-cache';
|
|
3
3
|
const config = {
|
|
4
|
+
// =============================================================================
|
|
5
|
+
// metaschema_public tables
|
|
6
|
+
// =============================================================================
|
|
4
7
|
database: {
|
|
5
8
|
schema: 'metaschema_public',
|
|
6
9
|
table: 'database',
|
|
@@ -44,6 +47,10 @@ const config = {
|
|
|
44
47
|
field: {
|
|
45
48
|
schema: 'metaschema_public',
|
|
46
49
|
table: 'field',
|
|
50
|
+
// Use ON CONFLICT DO NOTHING to handle the unique constraint (databases_field_uniq_names_idx)
|
|
51
|
+
// which normalizes UUID field names by stripping suffixes like _id, _uuid, etc.
|
|
52
|
+
// This causes collisions when tables have both 'foo' (text) and 'foo_id' (uuid) columns.
|
|
53
|
+
conflictDoNothing: true,
|
|
47
54
|
fields: {
|
|
48
55
|
id: 'uuid',
|
|
49
56
|
database_id: 'uuid',
|
|
@@ -53,6 +60,183 @@ const config = {
|
|
|
53
60
|
description: 'text'
|
|
54
61
|
}
|
|
55
62
|
},
|
|
63
|
+
policy: {
|
|
64
|
+
schema: 'metaschema_public',
|
|
65
|
+
table: 'policy',
|
|
66
|
+
fields: {
|
|
67
|
+
id: 'uuid',
|
|
68
|
+
database_id: 'uuid',
|
|
69
|
+
table_id: 'uuid',
|
|
70
|
+
name: 'text',
|
|
71
|
+
role_name: 'text',
|
|
72
|
+
privilege: 'text',
|
|
73
|
+
permissive: 'boolean',
|
|
74
|
+
disabled: 'boolean',
|
|
75
|
+
template: 'text',
|
|
76
|
+
data: 'jsonb'
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
index: {
|
|
80
|
+
schema: 'metaschema_public',
|
|
81
|
+
table: 'index',
|
|
82
|
+
fields: {
|
|
83
|
+
id: 'uuid',
|
|
84
|
+
database_id: 'uuid',
|
|
85
|
+
table_id: 'uuid',
|
|
86
|
+
name: 'text',
|
|
87
|
+
field_ids: 'uuid[]',
|
|
88
|
+
include_field_ids: 'uuid[]',
|
|
89
|
+
access_method: 'text',
|
|
90
|
+
index_params: 'jsonb',
|
|
91
|
+
where_clause: 'jsonb',
|
|
92
|
+
is_unique: 'boolean'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
trigger: {
|
|
96
|
+
schema: 'metaschema_public',
|
|
97
|
+
table: 'trigger',
|
|
98
|
+
fields: {
|
|
99
|
+
id: 'uuid',
|
|
100
|
+
database_id: 'uuid',
|
|
101
|
+
table_id: 'uuid',
|
|
102
|
+
name: 'text',
|
|
103
|
+
event: 'text',
|
|
104
|
+
function_name: 'text'
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
trigger_function: {
|
|
108
|
+
schema: 'metaschema_public',
|
|
109
|
+
table: 'trigger_function',
|
|
110
|
+
fields: {
|
|
111
|
+
id: 'uuid',
|
|
112
|
+
database_id: 'uuid',
|
|
113
|
+
schema_id: 'uuid',
|
|
114
|
+
name: 'text'
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
rls_function: {
|
|
118
|
+
schema: 'metaschema_public',
|
|
119
|
+
table: 'rls_function',
|
|
120
|
+
fields: {
|
|
121
|
+
id: 'uuid',
|
|
122
|
+
database_id: 'uuid',
|
|
123
|
+
schema_id: 'uuid',
|
|
124
|
+
name: 'text'
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
limit_function: {
|
|
128
|
+
schema: 'metaschema_public',
|
|
129
|
+
table: 'limit_function',
|
|
130
|
+
fields: {
|
|
131
|
+
id: 'uuid',
|
|
132
|
+
database_id: 'uuid',
|
|
133
|
+
schema_id: 'uuid',
|
|
134
|
+
name: 'text'
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
procedure: {
|
|
138
|
+
schema: 'metaschema_public',
|
|
139
|
+
table: 'procedure',
|
|
140
|
+
fields: {
|
|
141
|
+
id: 'uuid',
|
|
142
|
+
database_id: 'uuid',
|
|
143
|
+
schema_id: 'uuid',
|
|
144
|
+
name: 'text'
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
foreign_key_constraint: {
|
|
148
|
+
schema: 'metaschema_public',
|
|
149
|
+
table: 'foreign_key_constraint',
|
|
150
|
+
fields: {
|
|
151
|
+
id: 'uuid',
|
|
152
|
+
database_id: 'uuid',
|
|
153
|
+
table_id: 'uuid',
|
|
154
|
+
name: 'text',
|
|
155
|
+
field_ids: 'uuid[]',
|
|
156
|
+
ref_table_id: 'uuid',
|
|
157
|
+
ref_field_ids: 'uuid[]',
|
|
158
|
+
on_delete: 'text',
|
|
159
|
+
on_update: 'text'
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
primary_key_constraint: {
|
|
163
|
+
schema: 'metaschema_public',
|
|
164
|
+
table: 'primary_key_constraint',
|
|
165
|
+
fields: {
|
|
166
|
+
id: 'uuid',
|
|
167
|
+
database_id: 'uuid',
|
|
168
|
+
table_id: 'uuid',
|
|
169
|
+
name: 'text',
|
|
170
|
+
field_ids: 'uuid[]'
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
unique_constraint: {
|
|
174
|
+
schema: 'metaschema_public',
|
|
175
|
+
table: 'unique_constraint',
|
|
176
|
+
fields: {
|
|
177
|
+
id: 'uuid',
|
|
178
|
+
database_id: 'uuid',
|
|
179
|
+
table_id: 'uuid',
|
|
180
|
+
name: 'text',
|
|
181
|
+
field_ids: 'uuid[]'
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
check_constraint: {
|
|
185
|
+
schema: 'metaschema_public',
|
|
186
|
+
table: 'check_constraint',
|
|
187
|
+
fields: {
|
|
188
|
+
id: 'uuid',
|
|
189
|
+
database_id: 'uuid',
|
|
190
|
+
table_id: 'uuid',
|
|
191
|
+
name: 'text',
|
|
192
|
+
expression: 'text'
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
full_text_search: {
|
|
196
|
+
schema: 'metaschema_public',
|
|
197
|
+
table: 'full_text_search',
|
|
198
|
+
fields: {
|
|
199
|
+
id: 'uuid',
|
|
200
|
+
database_id: 'uuid',
|
|
201
|
+
table_id: 'uuid',
|
|
202
|
+
name: 'text',
|
|
203
|
+
field_ids: 'uuid[]',
|
|
204
|
+
weights: 'text[]'
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
schema_grant: {
|
|
208
|
+
schema: 'metaschema_public',
|
|
209
|
+
table: 'schema_grant',
|
|
210
|
+
fields: {
|
|
211
|
+
id: 'uuid',
|
|
212
|
+
database_id: 'uuid',
|
|
213
|
+
schema_id: 'uuid',
|
|
214
|
+
role_name: 'text',
|
|
215
|
+
privilege: 'text'
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
table_grant: {
|
|
219
|
+
schema: 'metaschema_public',
|
|
220
|
+
table: 'table_grant',
|
|
221
|
+
fields: {
|
|
222
|
+
id: 'uuid',
|
|
223
|
+
database_id: 'uuid',
|
|
224
|
+
table_id: 'uuid',
|
|
225
|
+
role_name: 'text',
|
|
226
|
+
privilege: 'text'
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
extension: {
|
|
230
|
+
schema: 'metaschema_public',
|
|
231
|
+
table: 'extension',
|
|
232
|
+
fields: {
|
|
233
|
+
id: 'uuid',
|
|
234
|
+
name: 'text'
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
// =============================================================================
|
|
238
|
+
// services_public tables
|
|
239
|
+
// =============================================================================
|
|
56
240
|
domains: {
|
|
57
241
|
schema: 'services_public',
|
|
58
242
|
table: 'domains',
|
|
@@ -129,6 +313,18 @@ const config = {
|
|
|
129
313
|
theme: 'jsonb'
|
|
130
314
|
}
|
|
131
315
|
},
|
|
316
|
+
site_metadata: {
|
|
317
|
+
schema: 'services_public',
|
|
318
|
+
table: 'site_metadata',
|
|
319
|
+
fields: {
|
|
320
|
+
id: 'uuid',
|
|
321
|
+
database_id: 'uuid',
|
|
322
|
+
site_id: 'uuid',
|
|
323
|
+
title: 'text',
|
|
324
|
+
description: 'text',
|
|
325
|
+
og_image: 'image'
|
|
326
|
+
}
|
|
327
|
+
},
|
|
132
328
|
api_modules: {
|
|
133
329
|
schema: 'services_public',
|
|
134
330
|
table: 'api_modules',
|
|
@@ -150,9 +346,9 @@ const config = {
|
|
|
150
346
|
schema_name: 'text'
|
|
151
347
|
}
|
|
152
348
|
},
|
|
153
|
-
|
|
349
|
+
api_schemas: {
|
|
154
350
|
schema: 'services_public',
|
|
155
|
-
table: '
|
|
351
|
+
table: 'api_schemas',
|
|
156
352
|
fields: {
|
|
157
353
|
id: 'uuid',
|
|
158
354
|
database_id: 'uuid',
|
|
@@ -160,6 +356,9 @@ const config = {
|
|
|
160
356
|
api_id: 'uuid'
|
|
161
357
|
}
|
|
162
358
|
},
|
|
359
|
+
// =============================================================================
|
|
360
|
+
// metaschema_modules_public tables
|
|
361
|
+
// =============================================================================
|
|
163
362
|
rls_module: {
|
|
164
363
|
schema: 'metaschema_modules_public',
|
|
165
364
|
table: 'rls_module',
|
|
@@ -203,6 +402,375 @@ const config = {
|
|
|
203
402
|
send_verification_email_function: 'text',
|
|
204
403
|
verify_email_function: 'text'
|
|
205
404
|
}
|
|
405
|
+
},
|
|
406
|
+
memberships_module: {
|
|
407
|
+
schema: 'metaschema_modules_public',
|
|
408
|
+
table: 'memberships_module',
|
|
409
|
+
fields: {
|
|
410
|
+
id: 'uuid',
|
|
411
|
+
database_id: 'uuid',
|
|
412
|
+
schema_id: 'uuid',
|
|
413
|
+
private_schema_id: 'uuid',
|
|
414
|
+
memberships_table_id: 'uuid',
|
|
415
|
+
memberships_table_name: 'text',
|
|
416
|
+
members_table_id: 'uuid',
|
|
417
|
+
members_table_name: 'text',
|
|
418
|
+
membership_defaults_table_id: 'uuid',
|
|
419
|
+
membership_defaults_table_name: 'text',
|
|
420
|
+
grants_table_id: 'uuid',
|
|
421
|
+
grants_table_name: 'text',
|
|
422
|
+
actor_table_id: 'uuid',
|
|
423
|
+
limits_table_id: 'uuid',
|
|
424
|
+
default_limits_table_id: 'uuid',
|
|
425
|
+
permissions_table_id: 'uuid',
|
|
426
|
+
default_permissions_table_id: 'uuid',
|
|
427
|
+
sprt_table_id: 'uuid',
|
|
428
|
+
admin_grants_table_id: 'uuid',
|
|
429
|
+
admin_grants_table_name: 'text',
|
|
430
|
+
owner_grants_table_id: 'uuid',
|
|
431
|
+
owner_grants_table_name: 'text',
|
|
432
|
+
membership_type: 'int',
|
|
433
|
+
entity_table_id: 'uuid',
|
|
434
|
+
entity_table_owner_id: 'uuid',
|
|
435
|
+
prefix: 'text',
|
|
436
|
+
actor_mask_check: 'text',
|
|
437
|
+
actor_perm_check: 'text',
|
|
438
|
+
entity_ids_by_mask: 'text',
|
|
439
|
+
entity_ids_by_perm: 'text',
|
|
440
|
+
entity_ids_function: 'text'
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
permissions_module: {
|
|
444
|
+
schema: 'metaschema_modules_public',
|
|
445
|
+
table: 'permissions_module',
|
|
446
|
+
fields: {
|
|
447
|
+
id: 'uuid',
|
|
448
|
+
database_id: 'uuid',
|
|
449
|
+
schema_id: 'uuid',
|
|
450
|
+
private_schema_id: 'uuid',
|
|
451
|
+
table_id: 'uuid',
|
|
452
|
+
table_name: 'text',
|
|
453
|
+
default_table_id: 'uuid',
|
|
454
|
+
default_table_name: 'text',
|
|
455
|
+
bitlen: 'int',
|
|
456
|
+
membership_type: 'int',
|
|
457
|
+
entity_table_id: 'uuid',
|
|
458
|
+
actor_table_id: 'uuid',
|
|
459
|
+
prefix: 'text',
|
|
460
|
+
get_padded_mask: 'text',
|
|
461
|
+
get_mask: 'text',
|
|
462
|
+
get_by_mask: 'text',
|
|
463
|
+
get_mask_by_name: 'text'
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
limits_module: {
|
|
467
|
+
schema: 'metaschema_modules_public',
|
|
468
|
+
table: 'limits_module',
|
|
469
|
+
fields: {
|
|
470
|
+
id: 'uuid',
|
|
471
|
+
database_id: 'uuid',
|
|
472
|
+
schema_id: 'uuid',
|
|
473
|
+
private_schema_id: 'uuid',
|
|
474
|
+
table_id: 'uuid',
|
|
475
|
+
table_name: 'text',
|
|
476
|
+
default_table_id: 'uuid',
|
|
477
|
+
default_table_name: 'text',
|
|
478
|
+
limit_increment_function: 'text',
|
|
479
|
+
limit_decrement_function: 'text',
|
|
480
|
+
limit_increment_trigger: 'text',
|
|
481
|
+
limit_decrement_trigger: 'text',
|
|
482
|
+
limit_update_trigger: 'text',
|
|
483
|
+
limit_check_function: 'text',
|
|
484
|
+
prefix: 'text',
|
|
485
|
+
membership_type: 'int',
|
|
486
|
+
entity_table_id: 'uuid',
|
|
487
|
+
actor_table_id: 'uuid'
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
levels_module: {
|
|
491
|
+
schema: 'metaschema_modules_public',
|
|
492
|
+
table: 'levels_module',
|
|
493
|
+
fields: {
|
|
494
|
+
id: 'uuid',
|
|
495
|
+
database_id: 'uuid',
|
|
496
|
+
schema_id: 'uuid',
|
|
497
|
+
private_schema_id: 'uuid',
|
|
498
|
+
steps_table_id: 'uuid',
|
|
499
|
+
steps_table_name: 'text',
|
|
500
|
+
achievements_table_id: 'uuid',
|
|
501
|
+
achievements_table_name: 'text',
|
|
502
|
+
levels_table_id: 'uuid',
|
|
503
|
+
levels_table_name: 'text',
|
|
504
|
+
level_requirements_table_id: 'uuid',
|
|
505
|
+
level_requirements_table_name: 'text',
|
|
506
|
+
completed_step: 'text',
|
|
507
|
+
incompleted_step: 'text',
|
|
508
|
+
tg_achievement: 'text',
|
|
509
|
+
tg_achievement_toggle: 'text',
|
|
510
|
+
tg_achievement_toggle_boolean: 'text',
|
|
511
|
+
tg_achievement_boolean: 'text',
|
|
512
|
+
upsert_achievement: 'text',
|
|
513
|
+
tg_update_achievements: 'text',
|
|
514
|
+
steps_required: 'text',
|
|
515
|
+
level_achieved: 'text',
|
|
516
|
+
prefix: 'text',
|
|
517
|
+
membership_type: 'int',
|
|
518
|
+
entity_table_id: 'uuid',
|
|
519
|
+
actor_table_id: 'uuid'
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
users_module: {
|
|
523
|
+
schema: 'metaschema_modules_public',
|
|
524
|
+
table: 'users_module',
|
|
525
|
+
fields: {
|
|
526
|
+
id: 'uuid',
|
|
527
|
+
database_id: 'uuid',
|
|
528
|
+
schema_id: 'uuid',
|
|
529
|
+
table_id: 'uuid',
|
|
530
|
+
table_name: 'text',
|
|
531
|
+
type_table_id: 'uuid',
|
|
532
|
+
type_table_name: 'text'
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
hierarchy_module: {
|
|
536
|
+
schema: 'metaschema_modules_public',
|
|
537
|
+
table: 'hierarchy_module',
|
|
538
|
+
fields: {
|
|
539
|
+
id: 'uuid',
|
|
540
|
+
database_id: 'uuid',
|
|
541
|
+
schema_id: 'uuid',
|
|
542
|
+
private_schema_id: 'uuid',
|
|
543
|
+
chart_edges_table_id: 'uuid',
|
|
544
|
+
chart_edges_table_name: 'text',
|
|
545
|
+
hierarchy_sprt_table_id: 'uuid',
|
|
546
|
+
hierarchy_sprt_table_name: 'text',
|
|
547
|
+
chart_edge_grants_table_id: 'uuid',
|
|
548
|
+
chart_edge_grants_table_name: 'text',
|
|
549
|
+
entity_table_id: 'uuid',
|
|
550
|
+
users_table_id: 'uuid',
|
|
551
|
+
prefix: 'text',
|
|
552
|
+
private_schema_name: 'text',
|
|
553
|
+
sprt_table_name: 'text',
|
|
554
|
+
rebuild_hierarchy_function: 'text',
|
|
555
|
+
get_subordinates_function: 'text',
|
|
556
|
+
get_managers_function: 'text',
|
|
557
|
+
is_manager_of_function: 'text',
|
|
558
|
+
created_at: 'timestamptz'
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
membership_types_module: {
|
|
562
|
+
schema: 'metaschema_modules_public',
|
|
563
|
+
table: 'membership_types_module',
|
|
564
|
+
fields: {
|
|
565
|
+
id: 'uuid',
|
|
566
|
+
database_id: 'uuid',
|
|
567
|
+
schema_id: 'uuid',
|
|
568
|
+
table_id: 'uuid',
|
|
569
|
+
table_name: 'text'
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
invites_module: {
|
|
573
|
+
schema: 'metaschema_modules_public',
|
|
574
|
+
table: 'invites_module',
|
|
575
|
+
fields: {
|
|
576
|
+
id: 'uuid',
|
|
577
|
+
database_id: 'uuid',
|
|
578
|
+
schema_id: 'uuid',
|
|
579
|
+
private_schema_id: 'uuid',
|
|
580
|
+
emails_table_id: 'uuid',
|
|
581
|
+
users_table_id: 'uuid',
|
|
582
|
+
invites_table_id: 'uuid',
|
|
583
|
+
claimed_invites_table_id: 'uuid',
|
|
584
|
+
invites_table_name: 'text',
|
|
585
|
+
claimed_invites_table_name: 'text',
|
|
586
|
+
submit_invite_code_function: 'text',
|
|
587
|
+
prefix: 'text',
|
|
588
|
+
membership_type: 'int',
|
|
589
|
+
entity_table_id: 'uuid'
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
emails_module: {
|
|
593
|
+
schema: 'metaschema_modules_public',
|
|
594
|
+
table: 'emails_module',
|
|
595
|
+
fields: {
|
|
596
|
+
id: 'uuid',
|
|
597
|
+
database_id: 'uuid',
|
|
598
|
+
schema_id: 'uuid',
|
|
599
|
+
private_schema_id: 'uuid',
|
|
600
|
+
table_id: 'uuid',
|
|
601
|
+
owner_table_id: 'uuid',
|
|
602
|
+
table_name: 'text'
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
tokens_module: {
|
|
606
|
+
schema: 'metaschema_modules_public',
|
|
607
|
+
table: 'tokens_module',
|
|
608
|
+
fields: {
|
|
609
|
+
id: 'uuid',
|
|
610
|
+
database_id: 'uuid',
|
|
611
|
+
schema_id: 'uuid',
|
|
612
|
+
table_id: 'uuid',
|
|
613
|
+
owned_table_id: 'uuid',
|
|
614
|
+
tokens_default_expiration: 'interval',
|
|
615
|
+
tokens_table: 'text'
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
secrets_module: {
|
|
619
|
+
schema: 'metaschema_modules_public',
|
|
620
|
+
table: 'secrets_module',
|
|
621
|
+
fields: {
|
|
622
|
+
id: 'uuid',
|
|
623
|
+
database_id: 'uuid',
|
|
624
|
+
schema_id: 'uuid',
|
|
625
|
+
table_id: 'uuid',
|
|
626
|
+
table_name: 'text'
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
profiles_module: {
|
|
630
|
+
schema: 'metaschema_modules_public',
|
|
631
|
+
table: 'profiles_module',
|
|
632
|
+
fields: {
|
|
633
|
+
id: 'uuid',
|
|
634
|
+
database_id: 'uuid',
|
|
635
|
+
schema_id: 'uuid',
|
|
636
|
+
private_schema_id: 'uuid',
|
|
637
|
+
table_id: 'uuid',
|
|
638
|
+
table_name: 'text',
|
|
639
|
+
profile_permissions_table_id: 'uuid',
|
|
640
|
+
profile_permissions_table_name: 'text',
|
|
641
|
+
profile_grants_table_id: 'uuid',
|
|
642
|
+
profile_grants_table_name: 'text',
|
|
643
|
+
profile_definition_grants_table_id: 'uuid',
|
|
644
|
+
profile_definition_grants_table_name: 'text',
|
|
645
|
+
bitlen: 'int',
|
|
646
|
+
membership_type: 'int',
|
|
647
|
+
entity_table_id: 'uuid',
|
|
648
|
+
actor_table_id: 'uuid',
|
|
649
|
+
permissions_table_id: 'uuid',
|
|
650
|
+
memberships_table_id: 'uuid',
|
|
651
|
+
prefix: 'text'
|
|
652
|
+
}
|
|
653
|
+
},
|
|
654
|
+
encrypted_secrets_module: {
|
|
655
|
+
schema: 'metaschema_modules_public',
|
|
656
|
+
table: 'encrypted_secrets_module',
|
|
657
|
+
fields: {
|
|
658
|
+
id: 'uuid',
|
|
659
|
+
database_id: 'uuid',
|
|
660
|
+
schema_id: 'uuid',
|
|
661
|
+
table_id: 'uuid',
|
|
662
|
+
table_name: 'text'
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
connected_accounts_module: {
|
|
666
|
+
schema: 'metaschema_modules_public',
|
|
667
|
+
table: 'connected_accounts_module',
|
|
668
|
+
fields: {
|
|
669
|
+
id: 'uuid',
|
|
670
|
+
database_id: 'uuid',
|
|
671
|
+
schema_id: 'uuid',
|
|
672
|
+
private_schema_id: 'uuid',
|
|
673
|
+
table_id: 'uuid',
|
|
674
|
+
owner_table_id: 'uuid',
|
|
675
|
+
table_name: 'text'
|
|
676
|
+
}
|
|
677
|
+
},
|
|
678
|
+
phone_numbers_module: {
|
|
679
|
+
schema: 'metaschema_modules_public',
|
|
680
|
+
table: 'phone_numbers_module',
|
|
681
|
+
fields: {
|
|
682
|
+
id: 'uuid',
|
|
683
|
+
database_id: 'uuid',
|
|
684
|
+
schema_id: 'uuid',
|
|
685
|
+
private_schema_id: 'uuid',
|
|
686
|
+
table_id: 'uuid',
|
|
687
|
+
owner_table_id: 'uuid',
|
|
688
|
+
table_name: 'text'
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
crypto_addresses_module: {
|
|
692
|
+
schema: 'metaschema_modules_public',
|
|
693
|
+
table: 'crypto_addresses_module',
|
|
694
|
+
fields: {
|
|
695
|
+
id: 'uuid',
|
|
696
|
+
database_id: 'uuid',
|
|
697
|
+
schema_id: 'uuid',
|
|
698
|
+
private_schema_id: 'uuid',
|
|
699
|
+
table_id: 'uuid',
|
|
700
|
+
owner_table_id: 'uuid',
|
|
701
|
+
table_name: 'text',
|
|
702
|
+
crypto_network: 'text'
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
crypto_auth_module: {
|
|
706
|
+
schema: 'metaschema_modules_public',
|
|
707
|
+
table: 'crypto_auth_module',
|
|
708
|
+
fields: {
|
|
709
|
+
id: 'uuid',
|
|
710
|
+
database_id: 'uuid',
|
|
711
|
+
schema_id: 'uuid',
|
|
712
|
+
users_table_id: 'uuid',
|
|
713
|
+
tokens_table_id: 'uuid',
|
|
714
|
+
secrets_table_id: 'uuid',
|
|
715
|
+
addresses_table_id: 'uuid',
|
|
716
|
+
user_field: 'text',
|
|
717
|
+
crypto_network: 'text',
|
|
718
|
+
sign_in_request_challenge: 'text',
|
|
719
|
+
sign_in_record_failure: 'text',
|
|
720
|
+
sign_up_with_key: 'text',
|
|
721
|
+
sign_in_with_challenge: 'text'
|
|
722
|
+
}
|
|
723
|
+
},
|
|
724
|
+
field_module: {
|
|
725
|
+
schema: 'metaschema_modules_public',
|
|
726
|
+
table: 'field_module',
|
|
727
|
+
fields: {
|
|
728
|
+
id: 'uuid',
|
|
729
|
+
database_id: 'uuid',
|
|
730
|
+
private_schema_id: 'uuid',
|
|
731
|
+
table_id: 'uuid',
|
|
732
|
+
field_id: 'uuid',
|
|
733
|
+
data: 'jsonb',
|
|
734
|
+
triggers: 'text[]',
|
|
735
|
+
functions: 'text[]'
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
uuid_module: {
|
|
739
|
+
schema: 'metaschema_modules_public',
|
|
740
|
+
table: 'uuid_module',
|
|
741
|
+
fields: {
|
|
742
|
+
id: 'uuid',
|
|
743
|
+
database_id: 'uuid',
|
|
744
|
+
schema_id: 'uuid',
|
|
745
|
+
uuid_function: 'text',
|
|
746
|
+
uuid_seed: 'text'
|
|
747
|
+
}
|
|
748
|
+
},
|
|
749
|
+
default_ids_module: {
|
|
750
|
+
schema: 'metaschema_modules_public',
|
|
751
|
+
table: 'default_ids_module',
|
|
752
|
+
fields: {
|
|
753
|
+
id: 'uuid',
|
|
754
|
+
database_id: 'uuid'
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
denormalized_table_field: {
|
|
758
|
+
schema: 'metaschema_modules_public',
|
|
759
|
+
table: 'denormalized_table_field',
|
|
760
|
+
fields: {
|
|
761
|
+
id: 'uuid',
|
|
762
|
+
database_id: 'uuid',
|
|
763
|
+
table_id: 'uuid',
|
|
764
|
+
field_id: 'uuid',
|
|
765
|
+
set_ids: 'uuid[]',
|
|
766
|
+
ref_table_id: 'uuid',
|
|
767
|
+
ref_field_id: 'uuid',
|
|
768
|
+
ref_ids: 'uuid[]',
|
|
769
|
+
use_updates: 'boolean',
|
|
770
|
+
update_defaults: 'boolean',
|
|
771
|
+
func_name: 'text',
|
|
772
|
+
func_order: 'int'
|
|
773
|
+
}
|
|
206
774
|
}
|
|
207
775
|
};
|
|
208
776
|
export const exportMeta = async ({ opts, dbname, database_id }) => {
|
|
@@ -216,29 +784,84 @@ export const exportMeta = async ({ opts, dbname, database_id }) => {
|
|
|
216
784
|
return m;
|
|
217
785
|
}, {});
|
|
218
786
|
const queryAndParse = async (key, query) => {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
787
|
+
try {
|
|
788
|
+
const result = await pool.query(query, [database_id]);
|
|
789
|
+
if (result.rows.length) {
|
|
790
|
+
const parsed = await parsers[key].parse(result.rows);
|
|
791
|
+
if (parsed) {
|
|
792
|
+
sql[key] = parsed;
|
|
793
|
+
}
|
|
224
794
|
}
|
|
225
795
|
}
|
|
796
|
+
catch (err) {
|
|
797
|
+
const pgError = err;
|
|
798
|
+
if (pgError.code === '42P01') {
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
throw err;
|
|
802
|
+
}
|
|
226
803
|
};
|
|
804
|
+
// =============================================================================
|
|
805
|
+
// metaschema_public tables
|
|
806
|
+
// =============================================================================
|
|
227
807
|
await queryAndParse('database', `SELECT * FROM metaschema_public.database WHERE id = $1`);
|
|
808
|
+
await queryAndParse('database_extension', `SELECT * FROM metaschema_public.database_extension WHERE database_id = $1`);
|
|
228
809
|
await queryAndParse('schema', `SELECT * FROM metaschema_public.schema WHERE database_id = $1`);
|
|
229
810
|
await queryAndParse('table', `SELECT * FROM metaschema_public.table WHERE database_id = $1`);
|
|
230
811
|
await queryAndParse('field', `SELECT * FROM metaschema_public.field WHERE database_id = $1`);
|
|
812
|
+
await queryAndParse('policy', `SELECT * FROM metaschema_public.policy WHERE database_id = $1`);
|
|
813
|
+
await queryAndParse('index', `SELECT * FROM metaschema_public.index WHERE database_id = $1`);
|
|
814
|
+
await queryAndParse('trigger', `SELECT * FROM metaschema_public.trigger WHERE database_id = $1`);
|
|
815
|
+
await queryAndParse('trigger_function', `SELECT * FROM metaschema_public.trigger_function WHERE database_id = $1`);
|
|
816
|
+
await queryAndParse('rls_function', `SELECT * FROM metaschema_public.rls_function WHERE database_id = $1`);
|
|
817
|
+
await queryAndParse('limit_function', `SELECT * FROM metaschema_public.limit_function WHERE database_id = $1`);
|
|
818
|
+
await queryAndParse('procedure', `SELECT * FROM metaschema_public.procedure WHERE database_id = $1`);
|
|
819
|
+
await queryAndParse('foreign_key_constraint', `SELECT * FROM metaschema_public.foreign_key_constraint WHERE database_id = $1`);
|
|
820
|
+
await queryAndParse('primary_key_constraint', `SELECT * FROM metaschema_public.primary_key_constraint WHERE database_id = $1`);
|
|
821
|
+
await queryAndParse('unique_constraint', `SELECT * FROM metaschema_public.unique_constraint WHERE database_id = $1`);
|
|
822
|
+
await queryAndParse('check_constraint', `SELECT * FROM metaschema_public.check_constraint WHERE database_id = $1`);
|
|
823
|
+
await queryAndParse('full_text_search', `SELECT * FROM metaschema_public.full_text_search WHERE database_id = $1`);
|
|
824
|
+
await queryAndParse('schema_grant', `SELECT * FROM metaschema_public.schema_grant WHERE database_id = $1`);
|
|
825
|
+
await queryAndParse('table_grant', `SELECT * FROM metaschema_public.table_grant WHERE database_id = $1`);
|
|
826
|
+
await queryAndParse('extension', `SELECT * FROM metaschema_public.extension`);
|
|
827
|
+
// =============================================================================
|
|
828
|
+
// services_public tables
|
|
829
|
+
// =============================================================================
|
|
231
830
|
await queryAndParse('domains', `SELECT * FROM services_public.domains WHERE database_id = $1`);
|
|
232
|
-
await queryAndParse('apis', `SELECT * FROM services_public.apis WHERE database_id = $1`);
|
|
233
831
|
await queryAndParse('sites', `SELECT * FROM services_public.sites WHERE database_id = $1`);
|
|
234
|
-
await queryAndParse('
|
|
832
|
+
await queryAndParse('apis', `SELECT * FROM services_public.apis WHERE database_id = $1`);
|
|
833
|
+
await queryAndParse('apps', `SELECT * FROM services_public.apps WHERE database_id = $1`);
|
|
235
834
|
await queryAndParse('site_modules', `SELECT * FROM services_public.site_modules WHERE database_id = $1`);
|
|
236
835
|
await queryAndParse('site_themes', `SELECT * FROM services_public.site_themes WHERE database_id = $1`);
|
|
237
|
-
await queryAndParse('
|
|
238
|
-
await queryAndParse('
|
|
836
|
+
await queryAndParse('site_metadata', `SELECT * FROM services_public.site_metadata WHERE database_id = $1`);
|
|
837
|
+
await queryAndParse('api_modules', `SELECT * FROM services_public.api_modules WHERE database_id = $1`);
|
|
239
838
|
await queryAndParse('api_extensions', `SELECT * FROM services_public.api_extensions WHERE database_id = $1`);
|
|
240
|
-
await queryAndParse('
|
|
839
|
+
await queryAndParse('api_schemas', `SELECT * FROM services_public.api_schemas WHERE database_id = $1`);
|
|
840
|
+
// =============================================================================
|
|
841
|
+
// metaschema_modules_public tables
|
|
842
|
+
// =============================================================================
|
|
241
843
|
await queryAndParse('rls_module', `SELECT * FROM metaschema_modules_public.rls_module WHERE database_id = $1`);
|
|
242
844
|
await queryAndParse('user_auth_module', `SELECT * FROM metaschema_modules_public.user_auth_module WHERE database_id = $1`);
|
|
845
|
+
await queryAndParse('memberships_module', `SELECT * FROM metaschema_modules_public.memberships_module WHERE database_id = $1`);
|
|
846
|
+
await queryAndParse('permissions_module', `SELECT * FROM metaschema_modules_public.permissions_module WHERE database_id = $1`);
|
|
847
|
+
await queryAndParse('limits_module', `SELECT * FROM metaschema_modules_public.limits_module WHERE database_id = $1`);
|
|
848
|
+
await queryAndParse('levels_module', `SELECT * FROM metaschema_modules_public.levels_module WHERE database_id = $1`);
|
|
849
|
+
await queryAndParse('users_module', `SELECT * FROM metaschema_modules_public.users_module WHERE database_id = $1`);
|
|
850
|
+
await queryAndParse('hierarchy_module', `SELECT * FROM metaschema_modules_public.hierarchy_module WHERE database_id = $1`);
|
|
851
|
+
await queryAndParse('membership_types_module', `SELECT * FROM metaschema_modules_public.membership_types_module WHERE database_id = $1`);
|
|
852
|
+
await queryAndParse('invites_module', `SELECT * FROM metaschema_modules_public.invites_module WHERE database_id = $1`);
|
|
853
|
+
await queryAndParse('emails_module', `SELECT * FROM metaschema_modules_public.emails_module WHERE database_id = $1`);
|
|
854
|
+
await queryAndParse('tokens_module', `SELECT * FROM metaschema_modules_public.tokens_module WHERE database_id = $1`);
|
|
855
|
+
await queryAndParse('secrets_module', `SELECT * FROM metaschema_modules_public.secrets_module WHERE database_id = $1`);
|
|
856
|
+
await queryAndParse('profiles_module', `SELECT * FROM metaschema_modules_public.profiles_module WHERE database_id = $1`);
|
|
857
|
+
await queryAndParse('encrypted_secrets_module', `SELECT * FROM metaschema_modules_public.encrypted_secrets_module WHERE database_id = $1`);
|
|
858
|
+
await queryAndParse('connected_accounts_module', `SELECT * FROM metaschema_modules_public.connected_accounts_module WHERE database_id = $1`);
|
|
859
|
+
await queryAndParse('phone_numbers_module', `SELECT * FROM metaschema_modules_public.phone_numbers_module WHERE database_id = $1`);
|
|
860
|
+
await queryAndParse('crypto_addresses_module', `SELECT * FROM metaschema_modules_public.crypto_addresses_module WHERE database_id = $1`);
|
|
861
|
+
await queryAndParse('crypto_auth_module', `SELECT * FROM metaschema_modules_public.crypto_auth_module WHERE database_id = $1`);
|
|
862
|
+
await queryAndParse('field_module', `SELECT * FROM metaschema_modules_public.field_module WHERE database_id = $1`);
|
|
863
|
+
await queryAndParse('uuid_module', `SELECT * FROM metaschema_modules_public.uuid_module WHERE database_id = $1`);
|
|
864
|
+
await queryAndParse('default_ids_module', `SELECT * FROM metaschema_modules_public.default_ids_module WHERE database_id = $1`);
|
|
865
|
+
await queryAndParse('denormalized_table_field', `SELECT * FROM metaschema_modules_public.denormalized_table_field WHERE database_id = $1`);
|
|
243
866
|
return Object.entries(sql).reduce((m, [_, v]) => m + '\n\n' + v, '');
|
|
244
867
|
};
|