@pgpmjs/export 0.27.0 → 0.28.1
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-graphql-meta.js +28 -107
- package/esm/export-meta.js +33 -129
- package/esm/export-utils.js +69 -497
- package/esm/index.js +1 -1
- package/esm/meta-export-tables.json +590 -0
- package/export-graphql-meta.js +27 -106
- package/export-meta.js +32 -128
- package/export-utils.d.ts +52 -8
- package/export-utils.js +73 -498
- package/index.d.ts +2 -2
- package/index.js +2 -1
- package/meta-export-tables.json +590 -0
- package/package.json +5 -5
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Parser } from 'csv-to-pg';
|
|
9
9
|
import { toSnakeCase } from 'inflekt';
|
|
10
|
-
import { META_TABLE_CONFIG } from './export-utils';
|
|
10
|
+
import { getTimestampDefaultColumnsForTable, META_TABLE_CONFIG, META_TABLE_ORDER } from './export-utils';
|
|
11
11
|
import { buildFieldsFragment, getGraphQLQueryName, getGraphQLTypeName, graphqlRowToPostgresRow, intervalToPostgres, mapGraphQLTypeToFieldType } from './graphql-naming';
|
|
12
12
|
import { lookupByGqlType } from './type-map';
|
|
13
13
|
/**
|
|
@@ -57,7 +57,21 @@ const buildDynamicFieldsFromGraphQL = async (client, tableConfig) => {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
// Omit columns
|
|
60
|
+
// Omit timestamptz columns whose default supplies the current time. Their
|
|
61
|
+
// DDL DEFAULT will apply at deploy time, keeping generated INSERT rows
|
|
62
|
+
// free of literal environment-specific timestamps.
|
|
63
|
+
const timestampDefaultColumns = getTimestampDefaultColumnsForTable(tableConfig.schema, tableConfig.table);
|
|
64
|
+
if (timestampDefaultColumns.length > 0) {
|
|
65
|
+
tableConfig.columnDefaults = tableConfig.columnDefaults || {};
|
|
66
|
+
for (const colName of timestampDefaultColumns) {
|
|
67
|
+
if (dynamicFields[colName] === 'timestamptz') {
|
|
68
|
+
delete dynamicFields[colName];
|
|
69
|
+
enumFields.delete(colName);
|
|
70
|
+
tableConfig.columnDefaults[colName] = '';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Omit columns that are explicitly marked as columnDefaults — their DDL DEFAULT (e.g.
|
|
61
75
|
// current_database()) will supply the correct value at deploy time, so the
|
|
62
76
|
// exported INSERT must not hardcode an environment-specific literal.
|
|
63
77
|
if (tableConfig.columnDefaults) {
|
|
@@ -186,110 +200,17 @@ export const exportGraphQLMeta = async ({ client, database_id }) => {
|
|
|
186
200
|
};
|
|
187
201
|
// Batch queries by schema group — independent HTTP requests run in parallel
|
|
188
202
|
// within each group for significant speedup over sequential awaits.
|
|
189
|
-
//
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
queryAndParse(
|
|
200
|
-
|
|
201
|
-
queryAndParse('rls_function'),
|
|
202
|
-
queryAndParse('foreign_key_constraint'),
|
|
203
|
-
queryAndParse('primary_key_constraint'),
|
|
204
|
-
queryAndParse('unique_constraint'),
|
|
205
|
-
queryAndParse('check_constraint'),
|
|
206
|
-
queryAndParse('full_text_search'),
|
|
207
|
-
queryAndParse('schema_grant'),
|
|
208
|
-
queryAndParse('table_grant'),
|
|
209
|
-
queryAndParse('default_privilege')
|
|
210
|
-
]);
|
|
211
|
-
// services_public tables
|
|
212
|
-
await Promise.all([
|
|
213
|
-
queryAndParse('domains'),
|
|
214
|
-
queryAndParse('sites'),
|
|
215
|
-
queryAndParse('apis'),
|
|
216
|
-
queryAndParse('apps'),
|
|
217
|
-
queryAndParse('site_modules'),
|
|
218
|
-
queryAndParse('site_themes'),
|
|
219
|
-
queryAndParse('site_metadata'),
|
|
220
|
-
queryAndParse('api_modules'),
|
|
221
|
-
queryAndParse('api_extensions'),
|
|
222
|
-
queryAndParse('api_schemas'),
|
|
223
|
-
queryAndParse('database_settings'),
|
|
224
|
-
queryAndParse('api_settings'),
|
|
225
|
-
queryAndParse('rls_settings'),
|
|
226
|
-
queryAndParse('cors_settings'),
|
|
227
|
-
queryAndParse('pubkey_settings'),
|
|
228
|
-
queryAndParse('webauthn_settings')
|
|
229
|
-
]);
|
|
230
|
-
// metaschema_modules_public tables
|
|
231
|
-
await Promise.all([
|
|
232
|
-
queryAndParse('rls_module'),
|
|
233
|
-
queryAndParse('user_auth_module'),
|
|
234
|
-
queryAndParse('memberships_module'),
|
|
235
|
-
queryAndParse('permissions_module'),
|
|
236
|
-
queryAndParse('limits_module'),
|
|
237
|
-
queryAndParse('levels_module'),
|
|
238
|
-
queryAndParse('events_module'),
|
|
239
|
-
queryAndParse('users_module'),
|
|
240
|
-
queryAndParse('hierarchy_module'),
|
|
241
|
-
queryAndParse('membership_types_module'),
|
|
242
|
-
queryAndParse('invites_module'),
|
|
243
|
-
queryAndParse('emails_module'),
|
|
244
|
-
queryAndParse('sessions_module'),
|
|
245
|
-
queryAndParse('user_state_module'),
|
|
246
|
-
queryAndParse('profiles_module'),
|
|
247
|
-
queryAndParse('config_secrets_user_module'),
|
|
248
|
-
queryAndParse('user_credentials_module'),
|
|
249
|
-
queryAndParse('user_settings_module'),
|
|
250
|
-
queryAndParse('connected_accounts_module'),
|
|
251
|
-
queryAndParse('phone_numbers_module'),
|
|
252
|
-
queryAndParse('crypto_addresses_module'),
|
|
253
|
-
queryAndParse('crypto_auth_module'),
|
|
254
|
-
queryAndParse('field_module'),
|
|
255
|
-
queryAndParse('table_module'),
|
|
256
|
-
queryAndParse('secure_table_provision'),
|
|
257
|
-
queryAndParse('uuid_module'),
|
|
258
|
-
queryAndParse('default_ids_module'),
|
|
259
|
-
queryAndParse('denormalized_table_field'),
|
|
260
|
-
queryAndParse('relation_provision'),
|
|
261
|
-
queryAndParse('entity_type_provision'),
|
|
262
|
-
queryAndParse('rate_limits_module'),
|
|
263
|
-
queryAndParse('storage_module'),
|
|
264
|
-
queryAndParse('billing_module'),
|
|
265
|
-
queryAndParse('billing_provider_module'),
|
|
266
|
-
queryAndParse('devices_module'),
|
|
267
|
-
queryAndParse('identity_providers_module'),
|
|
268
|
-
queryAndParse('integration_providers_module'),
|
|
269
|
-
queryAndParse('notifications_module'),
|
|
270
|
-
queryAndParse('plans_module'),
|
|
271
|
-
queryAndParse('realtime_module'),
|
|
272
|
-
queryAndParse('session_secrets_module'),
|
|
273
|
-
queryAndParse('infra_secrets_module'),
|
|
274
|
-
queryAndParse('infra_config_module'),
|
|
275
|
-
queryAndParse('internal_secrets_module'),
|
|
276
|
-
queryAndParse('i18n_module'),
|
|
277
|
-
queryAndParse('agent_module'),
|
|
278
|
-
queryAndParse('function_module'),
|
|
279
|
-
queryAndParse('namespace_module'),
|
|
280
|
-
queryAndParse('merkle_store_module'),
|
|
281
|
-
queryAndParse('graph_module'),
|
|
282
|
-
queryAndParse('graph_execution_module'),
|
|
283
|
-
queryAndParse('function_deployment_module'),
|
|
284
|
-
queryAndParse('function_invocation_module'),
|
|
285
|
-
queryAndParse('compute_log_module'),
|
|
286
|
-
queryAndParse('db_usage_module'),
|
|
287
|
-
queryAndParse('storage_log_module'),
|
|
288
|
-
queryAndParse('transfer_log_module'),
|
|
289
|
-
queryAndParse('webauthn_auth_module'),
|
|
290
|
-
queryAndParse('webauthn_credentials_module'),
|
|
291
|
-
queryAndParse('inference_log_module'),
|
|
292
|
-
queryAndParse('rate_limit_meters_module')
|
|
293
|
-
]);
|
|
203
|
+
// Tables come from the generated manifest (see export-utils.ts); groups run
|
|
204
|
+
// sequentially in manifest schema order.
|
|
205
|
+
const keysBySchema = new Map();
|
|
206
|
+
for (const key of META_TABLE_ORDER) {
|
|
207
|
+
const schema = META_TABLE_CONFIG[key].schema;
|
|
208
|
+
if (!keysBySchema.has(schema))
|
|
209
|
+
keysBySchema.set(schema, []);
|
|
210
|
+
keysBySchema.get(schema).push(key);
|
|
211
|
+
}
|
|
212
|
+
for (const keys of keysBySchema.values()) {
|
|
213
|
+
await Promise.all(keys.map(key => queryAndParse(key)));
|
|
214
|
+
}
|
|
294
215
|
return sql;
|
|
295
216
|
};
|
package/esm/export-meta.js
CHANGED
|
@@ -1,39 +1,30 @@
|
|
|
1
1
|
import { Parser } from 'csv-to-pg';
|
|
2
2
|
import { getPgPool } from 'pg-cache';
|
|
3
|
-
import {
|
|
4
|
-
/**
|
|
5
|
-
* Query actual columns from information_schema for a given table.
|
|
6
|
-
* Returns a map of column_name -> udt_name (PostgreSQL type).
|
|
7
|
-
*/
|
|
8
|
-
const getTableColumns = async (pool, schemaName, tableName) => {
|
|
9
|
-
const result = await pool.query(`
|
|
10
|
-
SELECT column_name, udt_name
|
|
11
|
-
FROM information_schema.columns
|
|
12
|
-
WHERE table_schema = $1 AND table_name = $2
|
|
13
|
-
ORDER BY ordinal_position
|
|
14
|
-
`, [schemaName, tableName]);
|
|
15
|
-
const columns = new Map();
|
|
16
|
-
for (const row of result.rows) {
|
|
17
|
-
columns.set(row.column_name, row.udt_name);
|
|
18
|
-
}
|
|
19
|
-
return columns;
|
|
20
|
-
};
|
|
3
|
+
import { getTableColumnsWithDefaults, isTimestampDefaultColumn, mapPgTypeToFieldType, META_TABLE_CONFIG, META_TABLE_ORDER } from './export-utils';
|
|
21
4
|
/**
|
|
22
5
|
* Build dynamic fields config from the database via information_schema.
|
|
23
6
|
* - All fields are derived from `information_schema.columns` + `mapPgTypeToFieldType`.
|
|
24
7
|
* - `typeOverrides` from the config are applied on top for special types
|
|
25
8
|
* (image, upload, url) that cannot be inferred from PG types alone.
|
|
9
|
+
* - `timestamptz` columns with non-deterministic timestamp defaults (now(),
|
|
10
|
+
* CURRENT_TIMESTAMP, clock_timestamp(), or now() + interval) are omitted so
|
|
11
|
+
* their DDL DEFAULT supplies the value at deploy time.
|
|
26
12
|
*/
|
|
27
13
|
const buildDynamicFields = async (pool, tableConfig) => {
|
|
28
|
-
const actualColumns = await
|
|
14
|
+
const actualColumns = await getTableColumnsWithDefaults(pool, tableConfig.schema, tableConfig.table);
|
|
29
15
|
if (actualColumns.size === 0) {
|
|
30
16
|
// Table doesn't exist, return empty fields
|
|
31
17
|
return {};
|
|
32
18
|
}
|
|
33
19
|
const dynamicFields = {};
|
|
20
|
+
const timestampDefaultColumns = [];
|
|
34
21
|
// Derive all fields from information_schema
|
|
35
|
-
for (const [columnName,
|
|
36
|
-
|
|
22
|
+
for (const [columnName, { udt_name, column_default }] of actualColumns) {
|
|
23
|
+
const fieldType = mapPgTypeToFieldType(udt_name);
|
|
24
|
+
dynamicFields[columnName] = fieldType;
|
|
25
|
+
if (fieldType === 'timestamptz' && isTimestampDefaultColumn(column_default)) {
|
|
26
|
+
timestampDefaultColumns.push(columnName);
|
|
27
|
+
}
|
|
37
28
|
}
|
|
38
29
|
// Apply type overrides (image, upload, url)
|
|
39
30
|
if (tableConfig.typeOverrides) {
|
|
@@ -43,9 +34,19 @@ const buildDynamicFields = async (pool, tableConfig) => {
|
|
|
43
34
|
}
|
|
44
35
|
}
|
|
45
36
|
}
|
|
46
|
-
// Omit columns
|
|
47
|
-
//
|
|
48
|
-
//
|
|
37
|
+
// Omit timestamptz columns whose default supplies the current time. Their
|
|
38
|
+
// DDL DEFAULT will apply at deploy time, keeping generated INSERT rows
|
|
39
|
+
// free of literal environment-specific timestamps.
|
|
40
|
+
if (timestampDefaultColumns.length > 0) {
|
|
41
|
+
tableConfig.columnDefaults = tableConfig.columnDefaults || {};
|
|
42
|
+
for (const colName of timestampDefaultColumns) {
|
|
43
|
+
delete dynamicFields[colName];
|
|
44
|
+
tableConfig.columnDefaults[colName] = actualColumns.get(colName)?.column_default || '';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Omit columns that are explicitly marked as columnDefaults — their DDL
|
|
48
|
+
// DEFAULT (e.g. current_database()) will supply the correct value at deploy
|
|
49
|
+
// time, so the exported INSERT must not hardcode an environment-specific literal.
|
|
49
50
|
if (tableConfig.columnDefaults) {
|
|
50
51
|
for (const colName of Object.keys(tableConfig.columnDefaults)) {
|
|
51
52
|
delete dynamicFields[colName];
|
|
@@ -137,110 +138,13 @@ export const exportMeta = async ({ opts, dbname, database_id }) => {
|
|
|
137
138
|
throw err;
|
|
138
139
|
}
|
|
139
140
|
};
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
await queryAndParse('field', `SELECT * FROM metaschema_public.field WHERE database_id = $1 ORDER BY id`);
|
|
149
|
-
await queryAndParse('policy', `SELECT * FROM metaschema_public.policy WHERE database_id = $1 ORDER BY id`);
|
|
150
|
-
await queryAndParse('index', `SELECT * FROM metaschema_public.index WHERE database_id = $1 ORDER BY id`);
|
|
151
|
-
await queryAndParse('trigger', `SELECT * FROM metaschema_public.trigger WHERE database_id = $1 ORDER BY id`);
|
|
152
|
-
await queryAndParse('trigger_function', `SELECT * FROM metaschema_public.trigger_function WHERE database_id = $1 ORDER BY id`);
|
|
153
|
-
await queryAndParse('rls_function', `SELECT * FROM metaschema_public.rls_function WHERE database_id = $1 ORDER BY id`);
|
|
154
|
-
await queryAndParse('foreign_key_constraint', `SELECT * FROM metaschema_public.foreign_key_constraint WHERE database_id = $1 ORDER BY id`);
|
|
155
|
-
await queryAndParse('primary_key_constraint', `SELECT * FROM metaschema_public.primary_key_constraint WHERE database_id = $1 ORDER BY id`);
|
|
156
|
-
await queryAndParse('unique_constraint', `SELECT * FROM metaschema_public.unique_constraint WHERE database_id = $1 ORDER BY id`);
|
|
157
|
-
await queryAndParse('check_constraint', `SELECT * FROM metaschema_public.check_constraint WHERE database_id = $1 ORDER BY id`);
|
|
158
|
-
await queryAndParse('full_text_search', `SELECT * FROM metaschema_public.full_text_search WHERE database_id = $1 ORDER BY id`);
|
|
159
|
-
await queryAndParse('schema_grant', `SELECT * FROM metaschema_public.schema_grant WHERE database_id = $1 ORDER BY id`);
|
|
160
|
-
await queryAndParse('table_grant', `SELECT * FROM metaschema_public.table_grant WHERE database_id = $1 ORDER BY id`);
|
|
161
|
-
await queryAndParse('default_privilege', `SELECT * FROM metaschema_public.default_privilege WHERE database_id = $1 ORDER BY id`);
|
|
162
|
-
// =============================================================================
|
|
163
|
-
// services_public tables
|
|
164
|
-
// =============================================================================
|
|
165
|
-
await queryAndParse('domains', `SELECT * FROM services_public.domains WHERE database_id = $1 ORDER BY id`);
|
|
166
|
-
await queryAndParse('sites', `SELECT * FROM services_public.sites WHERE database_id = $1 ORDER BY id`);
|
|
167
|
-
await queryAndParse('apis', `SELECT * FROM services_public.apis WHERE database_id = $1 ORDER BY id`);
|
|
168
|
-
await queryAndParse('apps', `SELECT * FROM services_public.apps WHERE database_id = $1 ORDER BY id`);
|
|
169
|
-
await queryAndParse('site_modules', `SELECT * FROM services_public.site_modules WHERE database_id = $1 ORDER BY id`);
|
|
170
|
-
await queryAndParse('site_themes', `SELECT * FROM services_public.site_themes WHERE database_id = $1 ORDER BY id`);
|
|
171
|
-
await queryAndParse('site_metadata', `SELECT * FROM services_public.site_metadata WHERE database_id = $1 ORDER BY id`);
|
|
172
|
-
await queryAndParse('api_modules', `SELECT * FROM services_public.api_modules WHERE database_id = $1 ORDER BY id`);
|
|
173
|
-
await queryAndParse('api_extensions', `SELECT * FROM services_public.api_extensions WHERE database_id = $1 ORDER BY id`);
|
|
174
|
-
await queryAndParse('api_schemas', `SELECT * FROM services_public.api_schemas WHERE database_id = $1 ORDER BY id`);
|
|
175
|
-
await queryAndParse('database_settings', `SELECT * FROM services_public.database_settings WHERE database_id = $1 ORDER BY id`);
|
|
176
|
-
await queryAndParse('api_settings', `SELECT * FROM services_public.api_settings WHERE database_id = $1 ORDER BY id`);
|
|
177
|
-
await queryAndParse('rls_settings', `SELECT * FROM services_public.rls_settings WHERE database_id = $1 ORDER BY id`);
|
|
178
|
-
await queryAndParse('cors_settings', `SELECT * FROM services_public.cors_settings WHERE database_id = $1 ORDER BY id`);
|
|
179
|
-
await queryAndParse('pubkey_settings', `SELECT * FROM services_public.pubkey_settings WHERE database_id = $1 ORDER BY id`);
|
|
180
|
-
await queryAndParse('webauthn_settings', `SELECT * FROM services_public.webauthn_settings WHERE database_id = $1 ORDER BY id`);
|
|
181
|
-
// =============================================================================
|
|
182
|
-
// metaschema_modules_public tables
|
|
183
|
-
// =============================================================================
|
|
184
|
-
await queryAndParse('rls_module', `SELECT * FROM metaschema_modules_public.rls_module WHERE database_id = $1 ORDER BY id`);
|
|
185
|
-
await queryAndParse('user_auth_module', `SELECT * FROM metaschema_modules_public.user_auth_module WHERE database_id = $1 ORDER BY id`);
|
|
186
|
-
await queryAndParse('memberships_module', `SELECT * FROM metaschema_modules_public.memberships_module WHERE database_id = $1 ORDER BY id`);
|
|
187
|
-
await queryAndParse('permissions_module', `SELECT * FROM metaschema_modules_public.permissions_module WHERE database_id = $1 ORDER BY id`);
|
|
188
|
-
await queryAndParse('limits_module', `SELECT * FROM metaschema_modules_public.limits_module WHERE database_id = $1 ORDER BY id`);
|
|
189
|
-
await queryAndParse('levels_module', `SELECT * FROM metaschema_modules_public.levels_module WHERE database_id = $1 ORDER BY id`);
|
|
190
|
-
await queryAndParse('events_module', `SELECT * FROM metaschema_modules_public.events_module WHERE database_id = $1 ORDER BY id`);
|
|
191
|
-
await queryAndParse('users_module', `SELECT * FROM metaschema_modules_public.users_module WHERE database_id = $1 ORDER BY id`);
|
|
192
|
-
await queryAndParse('hierarchy_module', `SELECT * FROM metaschema_modules_public.hierarchy_module WHERE database_id = $1 ORDER BY id`);
|
|
193
|
-
await queryAndParse('membership_types_module', `SELECT * FROM metaschema_modules_public.membership_types_module WHERE database_id = $1 ORDER BY id`);
|
|
194
|
-
await queryAndParse('invites_module', `SELECT * FROM metaschema_modules_public.invites_module WHERE database_id = $1 ORDER BY id`);
|
|
195
|
-
await queryAndParse('emails_module', `SELECT * FROM metaschema_modules_public.emails_module WHERE database_id = $1 ORDER BY id`);
|
|
196
|
-
await queryAndParse('sessions_module', `SELECT * FROM metaschema_modules_public.sessions_module WHERE database_id = $1 ORDER BY id`);
|
|
197
|
-
await queryAndParse('user_state_module', `SELECT * FROM metaschema_modules_public.user_state_module WHERE database_id = $1 ORDER BY id`);
|
|
198
|
-
await queryAndParse('profiles_module', `SELECT * FROM metaschema_modules_public.profiles_module WHERE database_id = $1 ORDER BY id`);
|
|
199
|
-
await queryAndParse('config_secrets_user_module', `SELECT * FROM metaschema_modules_public.config_secrets_user_module WHERE database_id = $1 ORDER BY id`);
|
|
200
|
-
await queryAndParse('user_credentials_module', `SELECT * FROM metaschema_modules_public.user_credentials_module WHERE database_id = $1 ORDER BY id`);
|
|
201
|
-
await queryAndParse('user_settings_module', `SELECT * FROM metaschema_modules_public.user_settings_module WHERE database_id = $1 ORDER BY id`);
|
|
202
|
-
await queryAndParse('connected_accounts_module', `SELECT * FROM metaschema_modules_public.connected_accounts_module WHERE database_id = $1 ORDER BY id`);
|
|
203
|
-
await queryAndParse('phone_numbers_module', `SELECT * FROM metaschema_modules_public.phone_numbers_module WHERE database_id = $1 ORDER BY id`);
|
|
204
|
-
await queryAndParse('crypto_addresses_module', `SELECT * FROM metaschema_modules_public.crypto_addresses_module WHERE database_id = $1 ORDER BY id`);
|
|
205
|
-
await queryAndParse('crypto_auth_module', `SELECT * FROM metaschema_modules_public.crypto_auth_module WHERE database_id = $1 ORDER BY id`);
|
|
206
|
-
await queryAndParse('field_module', `SELECT * FROM metaschema_modules_public.field_module WHERE database_id = $1 ORDER BY id`);
|
|
207
|
-
await queryAndParse('table_module', `SELECT * FROM metaschema_modules_public.table_module WHERE database_id = $1 ORDER BY id`);
|
|
208
|
-
await queryAndParse('secure_table_provision', `SELECT * FROM metaschema_modules_public.secure_table_provision WHERE database_id = $1 ORDER BY id`);
|
|
209
|
-
await queryAndParse('uuid_module', `SELECT * FROM metaschema_modules_public.uuid_module WHERE database_id = $1 ORDER BY id`);
|
|
210
|
-
await queryAndParse('default_ids_module', `SELECT * FROM metaschema_modules_public.default_ids_module WHERE database_id = $1 ORDER BY id`);
|
|
211
|
-
await queryAndParse('denormalized_table_field', `SELECT * FROM metaschema_modules_public.denormalized_table_field WHERE database_id = $1 ORDER BY id`);
|
|
212
|
-
await queryAndParse('relation_provision', `SELECT * FROM metaschema_modules_public.relation_provision WHERE database_id = $1 ORDER BY id`);
|
|
213
|
-
await queryAndParse('entity_type_provision', `SELECT * FROM metaschema_modules_public.entity_type_provision WHERE database_id = $1 ORDER BY id`);
|
|
214
|
-
await queryAndParse('rate_limits_module', `SELECT * FROM metaschema_modules_public.rate_limits_module WHERE database_id = $1 ORDER BY id`);
|
|
215
|
-
await queryAndParse('storage_module', `SELECT * FROM metaschema_modules_public.storage_module WHERE database_id = $1 ORDER BY id`);
|
|
216
|
-
await queryAndParse('billing_module', `SELECT * FROM metaschema_modules_public.billing_module WHERE database_id = $1 ORDER BY id`);
|
|
217
|
-
await queryAndParse('billing_provider_module', `SELECT * FROM metaschema_modules_public.billing_provider_module WHERE database_id = $1 ORDER BY id`);
|
|
218
|
-
await queryAndParse('devices_module', `SELECT * FROM metaschema_modules_public.devices_module WHERE database_id = $1 ORDER BY id`);
|
|
219
|
-
await queryAndParse('identity_providers_module', `SELECT * FROM metaschema_modules_public.identity_providers_module WHERE database_id = $1 ORDER BY id`);
|
|
220
|
-
await queryAndParse('integration_providers_module', `SELECT * FROM metaschema_modules_public.integration_providers_module WHERE database_id = $1 ORDER BY id`);
|
|
221
|
-
await queryAndParse('notifications_module', `SELECT * FROM metaschema_modules_public.notifications_module WHERE database_id = $1 ORDER BY id`);
|
|
222
|
-
await queryAndParse('plans_module', `SELECT * FROM metaschema_modules_public.plans_module WHERE database_id = $1 ORDER BY id`);
|
|
223
|
-
await queryAndParse('realtime_module', `SELECT * FROM metaschema_modules_public.realtime_module WHERE database_id = $1 ORDER BY id`);
|
|
224
|
-
await queryAndParse('session_secrets_module', `SELECT * FROM metaschema_modules_public.session_secrets_module WHERE database_id = $1 ORDER BY id`);
|
|
225
|
-
await queryAndParse('infra_secrets_module', `SELECT * FROM metaschema_modules_public.infra_secrets_module WHERE database_id = $1 ORDER BY id`);
|
|
226
|
-
await queryAndParse('infra_config_module', `SELECT * FROM metaschema_modules_public.infra_config_module WHERE database_id = $1 ORDER BY id`);
|
|
227
|
-
await queryAndParse('internal_secrets_module', `SELECT * FROM metaschema_modules_public.internal_secrets_module WHERE database_id = $1 ORDER BY id`);
|
|
228
|
-
await queryAndParse('i18n_module', `SELECT * FROM metaschema_modules_public.i18n_module WHERE database_id = $1 ORDER BY id`);
|
|
229
|
-
await queryAndParse('agent_module', `SELECT * FROM metaschema_modules_public.agent_module WHERE database_id = $1 ORDER BY id`);
|
|
230
|
-
await queryAndParse('function_module', `SELECT * FROM metaschema_modules_public.function_module WHERE database_id = $1 ORDER BY id`);
|
|
231
|
-
await queryAndParse('namespace_module', `SELECT * FROM metaschema_modules_public.namespace_module WHERE database_id = $1 ORDER BY id`);
|
|
232
|
-
await queryAndParse('merkle_store_module', `SELECT * FROM metaschema_modules_public.merkle_store_module WHERE database_id = $1 ORDER BY id`);
|
|
233
|
-
await queryAndParse('graph_module', `SELECT * FROM metaschema_modules_public.graph_module WHERE database_id = $1 ORDER BY id`);
|
|
234
|
-
await queryAndParse('graph_execution_module', `SELECT * FROM metaschema_modules_public.graph_execution_module WHERE database_id = $1 ORDER BY id`);
|
|
235
|
-
await queryAndParse('function_deployment_module', `SELECT * FROM metaschema_modules_public.function_deployment_module WHERE database_id = $1 ORDER BY id`);
|
|
236
|
-
await queryAndParse('function_invocation_module', `SELECT * FROM metaschema_modules_public.function_invocation_module WHERE database_id = $1 ORDER BY id`);
|
|
237
|
-
await queryAndParse('compute_log_module', `SELECT * FROM metaschema_modules_public.compute_log_module WHERE database_id = $1 ORDER BY id`);
|
|
238
|
-
await queryAndParse('db_usage_module', `SELECT * FROM metaschema_modules_public.db_usage_module WHERE database_id = $1 ORDER BY id`);
|
|
239
|
-
await queryAndParse('storage_log_module', `SELECT * FROM metaschema_modules_public.storage_log_module WHERE database_id = $1 ORDER BY id`);
|
|
240
|
-
await queryAndParse('transfer_log_module', `SELECT * FROM metaschema_modules_public.transfer_log_module WHERE database_id = $1 ORDER BY id`);
|
|
241
|
-
await queryAndParse('webauthn_auth_module', `SELECT * FROM metaschema_modules_public.webauthn_auth_module WHERE database_id = $1 ORDER BY id`);
|
|
242
|
-
await queryAndParse('webauthn_credentials_module', `SELECT * FROM metaschema_modules_public.webauthn_credentials_module WHERE database_id = $1 ORDER BY id`);
|
|
243
|
-
await queryAndParse('inference_log_module', `SELECT * FROM metaschema_modules_public.inference_log_module WHERE database_id = $1 ORDER BY id`);
|
|
244
|
-
await queryAndParse('rate_limit_meters_module', `SELECT * FROM metaschema_modules_public.rate_limit_meters_module WHERE database_id = $1 ORDER BY id`);
|
|
141
|
+
// Iterate the generated table manifest (already topologically sorted by FK
|
|
142
|
+
// dependencies). All tables are keyed by database_id except `database`
|
|
143
|
+
// itself, which is keyed by id.
|
|
144
|
+
for (const key of META_TABLE_ORDER) {
|
|
145
|
+
const tableConfig = META_TABLE_CONFIG[key];
|
|
146
|
+
const filterColumn = key === 'database' ? 'id' : 'database_id';
|
|
147
|
+
await queryAndParse(key, `SELECT * FROM ${tableConfig.schema}.${tableConfig.table} WHERE ${filterColumn} = $1 ORDER BY id`);
|
|
148
|
+
}
|
|
245
149
|
return sql;
|
|
246
150
|
};
|