@pgpmjs/export 1.1.1 → 1.2.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/README.md CHANGED
@@ -20,6 +20,13 @@ Export tools for extracting database migrations from existing PostgreSQL databas
20
20
  - **GraphQL Export** — Extract migrations via a PostGraphile GraphQL endpoint
21
21
  - **Cross-flow parity** — Both flows produce identical output for the same source data
22
22
  - **Metadata export** — Export metaschema, services, and module metadata tables
23
+ - **Table-data export** — Generic deterministic row-data dumps (`exportTablesData`,
24
+ `buildDataDeployScript` / `buildDataRevertScript` / `buildDataVerifyScript`): one
25
+ INSERT per table in stable order, volatile-default columns excluded via pg_catalog
26
+ volatility (no regex on default text), replayed under
27
+ `session_replication_role = replica`, with ID-precise reverts and divide-by-zero
28
+ verify checks. These scripts are the data/fixtures parts a `@pgpmjs/bundle`
29
+ envelope ships. All SQL is emitted through `@constructive-io/query-builder`.
23
30
 
24
31
  ## Usage
25
32
 
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * GraphQL equivalent of export-meta.ts.
3
3
  *
4
- * Fetches metadata from metaschema_public, services_public, and metaschema_modules_public
4
+ * Fetches metadata from metaschema_public, constructive_routing_public,
5
+ * constructive_apps_public, and metaschema_modules_public
5
6
  * via GraphQL queries instead of direct SQL, then uses the same csv-to-pg Parser to
6
7
  * generate SQL INSERT statements.
7
8
  */
@@ -23,7 +23,7 @@ const exportMigrationsToDisk = async ({ project, options, database, databaseId,
23
23
  const name = extensionName || db.rows[0].name;
24
24
  // When skipSchemaRenaming is true, pass empty schemas array to avoid renaming
25
25
  // This is useful for self-referential introspection where you want to apply
26
- // policies to real infrastructure schemas (metaschema_public, services_public, etc.)
26
+ // policies to real infrastructure schemas (metaschema_public, constructive_routing_public, etc.)
27
27
  const schemasForReplacement = skipSchemaRenaming
28
28
  ? []
29
29
  : schemas.rows.filter((schema) => schema_names.includes(schema.schema_name));
@@ -9,7 +9,9 @@
9
9
  * Examples:
10
10
  * metaschema_public.database -> databases (query), Database (type)
11
11
  * metaschema_public.foreign_key_constraint -> foreignKeyConstraints
12
- * services_public.api_schemas -> apiSchemas
12
+ * constructive_routing_public.api_schemas -> apiSchemas
13
+ * constructive_apps_public.apps -> apps
14
+ * metaschema_modules_public.api_surface_module -> apiSurfaceModules
13
15
  * db_migrate.sql_actions -> sqlActions
14
16
  * column database_id -> databaseId
15
17
  */
@@ -18,22 +18,22 @@
18
18
  },
19
19
  {
20
20
  "key": "apis",
21
- "schema": "services_public",
21
+ "schema": "constructive_routing_public",
22
22
  "table": "apis"
23
23
  },
24
24
  {
25
25
  "key": "database_settings",
26
- "schema": "services_public",
26
+ "schema": "constructive_routing_public",
27
27
  "table": "database_settings"
28
28
  },
29
29
  {
30
30
  "key": "managed_domains",
31
- "schema": "services_public",
31
+ "schema": "constructive_routing_public",
32
32
  "table": "managed_domains"
33
33
  },
34
34
  {
35
35
  "key": "sites",
36
- "schema": "services_public",
36
+ "schema": "constructive_routing_public",
37
37
  "table": "sites"
38
38
  },
39
39
  {
@@ -78,47 +78,47 @@
78
78
  },
79
79
  {
80
80
  "key": "api_modules",
81
- "schema": "services_public",
81
+ "schema": "constructive_routing_public",
82
82
  "table": "api_modules"
83
83
  },
84
84
  {
85
85
  "key": "api_schemas",
86
- "schema": "services_public",
86
+ "schema": "constructive_routing_public",
87
87
  "table": "api_schemas"
88
88
  },
89
89
  {
90
90
  "key": "api_settings",
91
- "schema": "services_public",
91
+ "schema": "constructive_routing_public",
92
92
  "table": "api_settings"
93
93
  },
94
94
  {
95
95
  "key": "apps",
96
- "schema": "services_public",
96
+ "schema": "constructive_apps_public",
97
97
  "table": "apps"
98
98
  },
99
99
  {
100
100
  "key": "cors_settings",
101
- "schema": "services_public",
101
+ "schema": "constructive_routing_public",
102
102
  "table": "cors_settings"
103
103
  },
104
104
  {
105
105
  "key": "domains",
106
- "schema": "services_public",
106
+ "schema": "constructive_routing_public",
107
107
  "table": "domains"
108
108
  },
109
109
  {
110
110
  "key": "site_metadata",
111
- "schema": "services_public",
111
+ "schema": "constructive_routing_public",
112
112
  "table": "site_metadata"
113
113
  },
114
114
  {
115
115
  "key": "site_modules",
116
- "schema": "services_public",
116
+ "schema": "constructive_routing_public",
117
117
  "table": "site_modules"
118
118
  },
119
119
  {
120
120
  "key": "site_themes",
121
- "schema": "services_public",
121
+ "schema": "constructive_routing_public",
122
122
  "table": "site_themes"
123
123
  },
124
124
  {
@@ -178,17 +178,17 @@
178
178
  },
179
179
  {
180
180
  "key": "http_routes",
181
- "schema": "services_public",
181
+ "schema": "constructive_routing_public",
182
182
  "table": "http_routes"
183
183
  },
184
184
  {
185
185
  "key": "pubkey_settings",
186
- "schema": "services_public",
186
+ "schema": "constructive_routing_public",
187
187
  "table": "pubkey_settings"
188
188
  },
189
189
  {
190
190
  "key": "rls_settings",
191
- "schema": "services_public",
191
+ "schema": "constructive_routing_public",
192
192
  "table": "rls_settings"
193
193
  },
194
194
  {
@@ -206,6 +206,11 @@
206
206
  "schema": "metaschema_modules_public",
207
207
  "table": "billing_provider_module"
208
208
  },
209
+ {
210
+ "key": "catalog_module",
211
+ "schema": "metaschema_modules_public",
212
+ "table": "catalog_module"
213
+ },
209
214
  {
210
215
  "key": "compute_log_module",
211
216
  "schema": "metaschema_modules_public",
@@ -231,6 +236,11 @@
231
236
  "schema": "metaschema_modules_public",
232
237
  "table": "crypto_auth_module"
233
238
  },
239
+ {
240
+ "key": "database_settings_module",
241
+ "schema": "metaschema_modules_public",
242
+ "table": "database_settings_module"
243
+ },
234
244
  {
235
245
  "key": "db_usage_module",
236
246
  "schema": "metaschema_modules_public",
@@ -473,9 +483,19 @@
473
483
  },
474
484
  {
475
485
  "key": "webauthn_settings",
476
- "schema": "services_public",
486
+ "schema": "constructive_routing_public",
477
487
  "table": "webauthn_settings"
478
488
  },
489
+ {
490
+ "key": "api_surface_module",
491
+ "schema": "metaschema_modules_public",
492
+ "table": "api_surface_module"
493
+ },
494
+ {
495
+ "key": "app_module",
496
+ "schema": "metaschema_modules_public",
497
+ "table": "app_module"
498
+ },
479
499
  {
480
500
  "key": "db_preset_module",
481
501
  "schema": "metaschema_modules_public",
@@ -486,6 +506,11 @@
486
506
  "schema": "metaschema_modules_public",
487
507
  "table": "denormalized_table_field"
488
508
  },
509
+ {
510
+ "key": "domain_module",
511
+ "schema": "metaschema_modules_public",
512
+ "table": "domain_module"
513
+ },
489
514
  {
490
515
  "key": "function_deployment_module",
491
516
  "schema": "metaschema_modules_public",
@@ -506,6 +531,11 @@
506
531
  "schema": "metaschema_modules_public",
507
532
  "table": "resource_module"
508
533
  },
534
+ {
535
+ "key": "site_surface_module",
536
+ "schema": "metaschema_modules_public",
537
+ "table": "site_surface_module"
538
+ },
509
539
  {
510
540
  "key": "webhook_module",
511
541
  "schema": "metaschema_modules_public",
@@ -520,9 +550,82 @@
520
550
  "key": "http_route_module",
521
551
  "schema": "metaschema_modules_public",
522
552
  "table": "http_route_module"
553
+ },
554
+ {
555
+ "key": "route_module",
556
+ "schema": "metaschema_modules_public",
557
+ "table": "route_module"
523
558
  }
524
559
  ],
525
560
  "timestampDefaultColumns": {
561
+ "constructive_apps_public.apps": [
562
+ "created_at",
563
+ "updated_at"
564
+ ],
565
+ "constructive_routing_public.api_modules": [
566
+ "created_at",
567
+ "updated_at"
568
+ ],
569
+ "constructive_routing_public.api_schemas": [
570
+ "created_at",
571
+ "updated_at"
572
+ ],
573
+ "constructive_routing_public.api_settings": [
574
+ "created_at",
575
+ "updated_at"
576
+ ],
577
+ "constructive_routing_public.apis": [
578
+ "created_at",
579
+ "updated_at"
580
+ ],
581
+ "constructive_routing_public.cors_settings": [
582
+ "created_at",
583
+ "updated_at"
584
+ ],
585
+ "constructive_routing_public.database_settings": [
586
+ "created_at",
587
+ "updated_at"
588
+ ],
589
+ "constructive_routing_public.domains": [
590
+ "created_at",
591
+ "updated_at"
592
+ ],
593
+ "constructive_routing_public.http_routes": [
594
+ "created_at",
595
+ "updated_at"
596
+ ],
597
+ "constructive_routing_public.managed_domains": [
598
+ "created_at",
599
+ "updated_at"
600
+ ],
601
+ "constructive_routing_public.pubkey_settings": [
602
+ "created_at",
603
+ "updated_at"
604
+ ],
605
+ "constructive_routing_public.rls_settings": [
606
+ "created_at",
607
+ "updated_at"
608
+ ],
609
+ "constructive_routing_public.site_metadata": [
610
+ "created_at",
611
+ "updated_at"
612
+ ],
613
+ "constructive_routing_public.site_modules": [
614
+ "created_at",
615
+ "updated_at"
616
+ ],
617
+ "constructive_routing_public.site_themes": [
618
+ "created_at",
619
+ "updated_at"
620
+ ],
621
+ "constructive_routing_public.sites": [
622
+ "created_at",
623
+ "updated_at"
624
+ ],
625
+ "constructive_routing_public.webauthn_settings": [
626
+ "created_at",
627
+ "updated_at"
628
+ ],
526
629
  "metaschema_modules_public.db_preset_module": [
527
630
  "created_at"
528
631
  ],
@@ -605,10 +708,6 @@
605
708
  "metaschema_public.unique_constraint": [
606
709
  "created_at",
607
710
  "updated_at"
608
- ],
609
- "services_public.http_routes": [
610
- "created_at",
611
- "updated_at"
612
711
  ]
613
712
  }
614
713
  }
@@ -4,7 +4,8 @@ exports.exportGraphQLMeta = void 0;
4
4
  /**
5
5
  * GraphQL equivalent of export-meta.ts.
6
6
  *
7
- * Fetches metadata from metaschema_public, services_public, and metaschema_modules_public
7
+ * Fetches metadata from metaschema_public, constructive_routing_public,
8
+ * constructive_apps_public, and metaschema_modules_public
8
9
  * via GraphQL queries instead of direct SQL, then uses the same csv-to-pg Parser to
9
10
  * generate SQL INSERT statements.
10
11
  */
@@ -26,7 +26,7 @@ interface ExportOptions {
26
26
  serviceOutdir?: string;
27
27
  /**
28
28
  * Skip schema name replacement for infrastructure schemas.
29
- * When true, schema names like metaschema_public, services_public will not be renamed.
29
+ * When true, schema names like metaschema_public, constructive_routing_public will not be renamed.
30
30
  * Useful for self-referential introspection where you want to apply policies to real schemas.
31
31
  */
32
32
  skipSchemaRenaming?: boolean;
@@ -26,7 +26,7 @@ const exportMigrationsToDisk = async ({ project, options, database, databaseId,
26
26
  const name = extensionName || db.rows[0].name;
27
27
  // When skipSchemaRenaming is true, pass empty schemas array to avoid renaming
28
28
  // This is useful for self-referential introspection where you want to apply
29
- // policies to real infrastructure schemas (metaschema_public, services_public, etc.)
29
+ // policies to real infrastructure schemas (metaschema_public, constructive_routing_public, etc.)
30
30
  const schemasForReplacement = skipSchemaRenaming
31
31
  ? []
32
32
  : schemas.rows.filter((schema) => schema_names.includes(schema.schema_name));
package/graphql-naming.js CHANGED
@@ -12,7 +12,9 @@ exports.getGraphQLTypeName = exports.mapGraphQLTypeToFieldType = exports.unwrapG
12
12
  * Examples:
13
13
  * metaschema_public.database -> databases (query), Database (type)
14
14
  * metaschema_public.foreign_key_constraint -> foreignKeyConstraints
15
- * services_public.api_schemas -> apiSchemas
15
+ * constructive_routing_public.api_schemas -> apiSchemas
16
+ * constructive_apps_public.apps -> apps
17
+ * metaschema_modules_public.api_surface_module -> apiSurfaceModules
16
18
  * db_migrate.sql_actions -> sqlActions
17
19
  * column database_id -> databaseId
18
20
  */
@@ -18,22 +18,22 @@
18
18
  },
19
19
  {
20
20
  "key": "apis",
21
- "schema": "services_public",
21
+ "schema": "constructive_routing_public",
22
22
  "table": "apis"
23
23
  },
24
24
  {
25
25
  "key": "database_settings",
26
- "schema": "services_public",
26
+ "schema": "constructive_routing_public",
27
27
  "table": "database_settings"
28
28
  },
29
29
  {
30
30
  "key": "managed_domains",
31
- "schema": "services_public",
31
+ "schema": "constructive_routing_public",
32
32
  "table": "managed_domains"
33
33
  },
34
34
  {
35
35
  "key": "sites",
36
- "schema": "services_public",
36
+ "schema": "constructive_routing_public",
37
37
  "table": "sites"
38
38
  },
39
39
  {
@@ -78,47 +78,47 @@
78
78
  },
79
79
  {
80
80
  "key": "api_modules",
81
- "schema": "services_public",
81
+ "schema": "constructive_routing_public",
82
82
  "table": "api_modules"
83
83
  },
84
84
  {
85
85
  "key": "api_schemas",
86
- "schema": "services_public",
86
+ "schema": "constructive_routing_public",
87
87
  "table": "api_schemas"
88
88
  },
89
89
  {
90
90
  "key": "api_settings",
91
- "schema": "services_public",
91
+ "schema": "constructive_routing_public",
92
92
  "table": "api_settings"
93
93
  },
94
94
  {
95
95
  "key": "apps",
96
- "schema": "services_public",
96
+ "schema": "constructive_apps_public",
97
97
  "table": "apps"
98
98
  },
99
99
  {
100
100
  "key": "cors_settings",
101
- "schema": "services_public",
101
+ "schema": "constructive_routing_public",
102
102
  "table": "cors_settings"
103
103
  },
104
104
  {
105
105
  "key": "domains",
106
- "schema": "services_public",
106
+ "schema": "constructive_routing_public",
107
107
  "table": "domains"
108
108
  },
109
109
  {
110
110
  "key": "site_metadata",
111
- "schema": "services_public",
111
+ "schema": "constructive_routing_public",
112
112
  "table": "site_metadata"
113
113
  },
114
114
  {
115
115
  "key": "site_modules",
116
- "schema": "services_public",
116
+ "schema": "constructive_routing_public",
117
117
  "table": "site_modules"
118
118
  },
119
119
  {
120
120
  "key": "site_themes",
121
- "schema": "services_public",
121
+ "schema": "constructive_routing_public",
122
122
  "table": "site_themes"
123
123
  },
124
124
  {
@@ -178,17 +178,17 @@
178
178
  },
179
179
  {
180
180
  "key": "http_routes",
181
- "schema": "services_public",
181
+ "schema": "constructive_routing_public",
182
182
  "table": "http_routes"
183
183
  },
184
184
  {
185
185
  "key": "pubkey_settings",
186
- "schema": "services_public",
186
+ "schema": "constructive_routing_public",
187
187
  "table": "pubkey_settings"
188
188
  },
189
189
  {
190
190
  "key": "rls_settings",
191
- "schema": "services_public",
191
+ "schema": "constructive_routing_public",
192
192
  "table": "rls_settings"
193
193
  },
194
194
  {
@@ -206,6 +206,11 @@
206
206
  "schema": "metaschema_modules_public",
207
207
  "table": "billing_provider_module"
208
208
  },
209
+ {
210
+ "key": "catalog_module",
211
+ "schema": "metaschema_modules_public",
212
+ "table": "catalog_module"
213
+ },
209
214
  {
210
215
  "key": "compute_log_module",
211
216
  "schema": "metaschema_modules_public",
@@ -231,6 +236,11 @@
231
236
  "schema": "metaschema_modules_public",
232
237
  "table": "crypto_auth_module"
233
238
  },
239
+ {
240
+ "key": "database_settings_module",
241
+ "schema": "metaschema_modules_public",
242
+ "table": "database_settings_module"
243
+ },
234
244
  {
235
245
  "key": "db_usage_module",
236
246
  "schema": "metaschema_modules_public",
@@ -473,9 +483,19 @@
473
483
  },
474
484
  {
475
485
  "key": "webauthn_settings",
476
- "schema": "services_public",
486
+ "schema": "constructive_routing_public",
477
487
  "table": "webauthn_settings"
478
488
  },
489
+ {
490
+ "key": "api_surface_module",
491
+ "schema": "metaschema_modules_public",
492
+ "table": "api_surface_module"
493
+ },
494
+ {
495
+ "key": "app_module",
496
+ "schema": "metaschema_modules_public",
497
+ "table": "app_module"
498
+ },
479
499
  {
480
500
  "key": "db_preset_module",
481
501
  "schema": "metaschema_modules_public",
@@ -486,6 +506,11 @@
486
506
  "schema": "metaschema_modules_public",
487
507
  "table": "denormalized_table_field"
488
508
  },
509
+ {
510
+ "key": "domain_module",
511
+ "schema": "metaschema_modules_public",
512
+ "table": "domain_module"
513
+ },
489
514
  {
490
515
  "key": "function_deployment_module",
491
516
  "schema": "metaschema_modules_public",
@@ -506,6 +531,11 @@
506
531
  "schema": "metaschema_modules_public",
507
532
  "table": "resource_module"
508
533
  },
534
+ {
535
+ "key": "site_surface_module",
536
+ "schema": "metaschema_modules_public",
537
+ "table": "site_surface_module"
538
+ },
509
539
  {
510
540
  "key": "webhook_module",
511
541
  "schema": "metaschema_modules_public",
@@ -520,9 +550,82 @@
520
550
  "key": "http_route_module",
521
551
  "schema": "metaschema_modules_public",
522
552
  "table": "http_route_module"
553
+ },
554
+ {
555
+ "key": "route_module",
556
+ "schema": "metaschema_modules_public",
557
+ "table": "route_module"
523
558
  }
524
559
  ],
525
560
  "timestampDefaultColumns": {
561
+ "constructive_apps_public.apps": [
562
+ "created_at",
563
+ "updated_at"
564
+ ],
565
+ "constructive_routing_public.api_modules": [
566
+ "created_at",
567
+ "updated_at"
568
+ ],
569
+ "constructive_routing_public.api_schemas": [
570
+ "created_at",
571
+ "updated_at"
572
+ ],
573
+ "constructive_routing_public.api_settings": [
574
+ "created_at",
575
+ "updated_at"
576
+ ],
577
+ "constructive_routing_public.apis": [
578
+ "created_at",
579
+ "updated_at"
580
+ ],
581
+ "constructive_routing_public.cors_settings": [
582
+ "created_at",
583
+ "updated_at"
584
+ ],
585
+ "constructive_routing_public.database_settings": [
586
+ "created_at",
587
+ "updated_at"
588
+ ],
589
+ "constructive_routing_public.domains": [
590
+ "created_at",
591
+ "updated_at"
592
+ ],
593
+ "constructive_routing_public.http_routes": [
594
+ "created_at",
595
+ "updated_at"
596
+ ],
597
+ "constructive_routing_public.managed_domains": [
598
+ "created_at",
599
+ "updated_at"
600
+ ],
601
+ "constructive_routing_public.pubkey_settings": [
602
+ "created_at",
603
+ "updated_at"
604
+ ],
605
+ "constructive_routing_public.rls_settings": [
606
+ "created_at",
607
+ "updated_at"
608
+ ],
609
+ "constructive_routing_public.site_metadata": [
610
+ "created_at",
611
+ "updated_at"
612
+ ],
613
+ "constructive_routing_public.site_modules": [
614
+ "created_at",
615
+ "updated_at"
616
+ ],
617
+ "constructive_routing_public.site_themes": [
618
+ "created_at",
619
+ "updated_at"
620
+ ],
621
+ "constructive_routing_public.sites": [
622
+ "created_at",
623
+ "updated_at"
624
+ ],
625
+ "constructive_routing_public.webauthn_settings": [
626
+ "created_at",
627
+ "updated_at"
628
+ ],
526
629
  "metaschema_modules_public.db_preset_module": [
527
630
  "created_at"
528
631
  ],
@@ -605,10 +708,6 @@
605
708
  "metaschema_public.unique_constraint": [
606
709
  "created_at",
607
710
  "updated_at"
608
- ],
609
- "services_public.http_routes": [
610
- "created_at",
611
- "updated_at"
612
711
  ]
613
712
  }
614
713
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpmjs/export",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PGPM export tools for SQL and GraphQL database migration extraction",
6
6
  "main": "index.js",
@@ -41,20 +41,20 @@
41
41
  "@pgsql/types": "^18.0.0",
42
42
  "@types/pg": "^8.20.0",
43
43
  "makage": "^0.3.0",
44
- "pgsql-test": "^5.0.4"
44
+ "pgsql-test": "^5.0.5"
45
45
  },
46
46
  "dependencies": {
47
47
  "@constructive-io/query-builder": "^3.0.1",
48
- "@pgpmjs/core": "^7.2.2",
49
- "@pgpmjs/migrate-client": "^1.0.4",
50
- "@pgpmjs/types": "^2.35.1",
51
- "csv-to-pg": "^4.0.0",
48
+ "@pgpmjs/core": "^7.3.0",
49
+ "@pgpmjs/migrate-client": "^1.0.5",
50
+ "@pgpmjs/types": "^2.36.0",
51
+ "csv-to-pg": "^4.0.1",
52
52
  "glob": "^13.0.6",
53
53
  "inflekt": "^0.7.1",
54
54
  "inquirerer": "^4.9.1",
55
55
  "pg": "^8.21.0",
56
- "pg-cache": "^3.15.2",
56
+ "pg-cache": "^3.15.3",
57
57
  "pg-env": "^1.18.1"
58
58
  },
59
- "gitHead": "d48f39ebd4b7dcbab22df7c57438c06efd9e223d"
59
+ "gitHead": "39db6d576bce7bc1de8123849f237b1695779d88"
60
60
  }