Skip to content

Commit 23dc3a2

Browse files
committed
chore: remove apiExtensions and database_extension references
Remove all references to the removed extension tables: - Remove apiExtensions from apiSelect and normalizeApiRecord in gql.ts - Remove database_extension and api_extensions configs from export-meta.ts - Remove database_extension and api_extensions from tableOrder in export-migrations.ts - Update tests to remove extension table references
1 parent 390f4dd commit 23dc3a2

File tree

5 files changed

+5
-78
lines changed

5 files changed

+5
-78
lines changed

graphql/server/__tests__/api.middleware.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ describe('api middleware helpers', () => {
2929
databaseId: 'db-1',
3030
isPublic: false,
3131
domains: connection([]),
32-
apiExtensions: connection([{ schemaName: 'ext_schema' }]),
3332
schemasByApiSchemaApiIdAndSchemaId: connection([
3433
{ schemaName: 'app_public' },
3534
]),
@@ -38,7 +37,7 @@ describe('api middleware helpers', () => {
3837
};
3938
const result = normalizeApiRecord(api);
4039

41-
expect(result.schema).toEqual(['ext_schema', 'app_public']);
40+
expect(result.schema).toEqual(['app_public']);
4241
});
4342

4443
it('builds domains from api domains', () => {
@@ -54,7 +53,6 @@ describe('api middleware helpers', () => {
5453
{ domain: 'example.org', subdomain: '' },
5554
{ domain: 'example.net', subdomain: '' },
5655
]),
57-
apiExtensions: connection([]),
5856
schemasByApiSchemaApiIdAndSchemaId: connection([]),
5957
apiModules: connection([]),
6058
rlsModule: null,
@@ -100,7 +98,6 @@ describe('api middleware helpers', () => {
10098
databaseId: 'db-1',
10199
isPublic: false,
102100
domains: connection([]),
103-
apiExtensions: connection([]),
104101
schemasByApiSchemaApiIdAndSchemaId: connection([
105102
{ schemaName: 'app_public' },
106103
]),

graphql/server/src/middleware/gql.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ export const apiSelect = {
3232
},
3333
first: connectionFirst,
3434
},
35-
apiExtensions: {
36-
select: { schemaName: true },
37-
first: connectionFirst,
38-
},
3935
schemasByApiSchemaApiIdAndSchemaId: {
4036
select: { schemaName: true },
4137
first: connectionFirst,
@@ -146,10 +142,7 @@ export const createGraphileOrm = (graphile: GraphileQuery) => {
146142
};
147143

148144
export const normalizeApiRecord = (api: ApiRecord): ApiStructure => {
149-
const schemaNames = (api.apiExtensions?.nodes ?? []).flatMap((node) =>
150-
node.schemaName ? [node.schemaName] : []
151-
);
152-
const additionalSchemas = (
145+
const schemaNames = (
153146
api.schemasByApiSchemaApiIdAndSchemaId?.nodes ?? []
154147
).flatMap((node) => (node.schemaName ? [node.schemaName] : []));
155148

@@ -169,7 +162,7 @@ export const normalizeApiRecord = (api: ApiRecord): ApiStructure => {
169162
dbname: api.dbname,
170163
anonRole: api.anonRole,
171164
roleName: api.roleName,
172-
schema: [...schemaNames, ...additionalSchemas],
165+
schema: schemaNames,
173166
apiModules:
174167
api.apiModules?.nodes?.map((node) => ({
175168
name: node.name,

pgpm/core/__tests__/export/export-meta.test.ts

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,6 @@ describe('Export Meta Config Validation', () => {
1818
});
1919

2020
describe('table name validation', () => {
21-
it('should use singular table name "database_extension" (not plural "database_extensions")', () => {
22-
// The actual table in metaschema_public is database_extension (singular)
23-
// This test ensures the config uses the correct table name
24-
25-
// Check that the config defines the table correctly
26-
expect(exportMetaSource).toContain("table: 'database_extension'");
27-
28-
// Ensure we're not using the incorrect plural form in the table definition
29-
// Note: We check specifically in the config section, not the query section
30-
const configSection = exportMetaSource.split('const config:')[1]?.split('interface ExportMetaParams')[0] || '';
31-
expect(configSection).not.toContain("table: 'database_extensions'");
32-
});
33-
34-
it('should query the correct table name in metaschema_public.database_extension', () => {
35-
// The query should use the correct singular table name
36-
expect(exportMetaSource).toContain('FROM metaschema_public.database_extension');
37-
});
38-
3921
it('should include field table in queries', () => {
4022
// The field table should be queried (it was missing before)
4123
expect(exportMetaSource).toContain("queryAndParse('field'");
@@ -47,7 +29,6 @@ describe('Export Meta Config Validation', () => {
4729
it('should include all required metaschema_public tables in config', () => {
4830
const requiredTables = [
4931
'database',
50-
'database_extension',
5132
'schema',
5233
'table',
5334
'field'
@@ -69,7 +50,6 @@ describe('Export Meta Config Validation', () => {
6950
'site_modules',
7051
'site_themes',
7152
'api_modules',
72-
'api_extensions',
7353
'api_schemas'
7454
];
7555

@@ -111,22 +91,19 @@ describe('Export Meta Config Drift Detection', () => {
11191
// If these change, the export-meta.ts config needs to be updated
11292
const expectedMetaschemaPublicTables = [
11393
'database',
114-
'database_extension', // NOT 'database_extensions' (plural)
11594
'schema',
11695
'table',
11796
'field'
11897
];
11998

12099
// Document the expected tables
121-
expect(expectedMetaschemaPublicTables).toContain('database_extension');
122-
expect(expectedMetaschemaPublicTables).not.toContain('database_extensions');
100+
expect(expectedMetaschemaPublicTables.length).toBe(4);
123101
});
124102

125103
it('should document the expected table names in services_public', () => {
126104
// This test documents the expected table names that export-meta.ts should use
127105
const expectedServicesPublicTables = [
128106
'apis',
129-
'api_extensions',
130107
'api_modules',
131108
'api_schemas',
132109
'apps',
@@ -137,7 +114,7 @@ describe('Export Meta Config Drift Detection', () => {
137114
];
138115

139116
// Document the expected tables
140-
expect(expectedServicesPublicTables.length).toBe(9);
117+
expect(expectedServicesPublicTables.length).toBe(8);
141118
});
142119

143120
it('should document the expected table names in metaschema_modules_public', () => {
@@ -151,24 +128,4 @@ describe('Export Meta Config Drift Detection', () => {
151128
expect(expectedMetaschemaModulesPublicTables.length).toBe(2);
152129
});
153130

154-
it('should document the bug: config uses database_extensions but table is database_extension', () => {
155-
// BUG DOCUMENTATION:
156-
// In export-meta.ts, line 26, the config defines:
157-
// table: 'database_extensions' (plural)
158-
// But the actual table in metaschema-schema is:
159-
// metaschema_public.database_extension (singular)
160-
//
161-
// This causes the Parser to generate INSERT statements with the wrong table name,
162-
// which will fail when the exported SQL is replayed.
163-
//
164-
// FIX: Change line 26 in export-meta.ts from:
165-
// table: 'database_extensions'
166-
// to:
167-
// table: 'database_extension'
168-
169-
const buggyConfigTableName = 'database_extensions';
170-
const correctTableName = 'database_extension';
171-
172-
expect(buggyConfigTableName).not.toBe(correctTableName);
173-
});
174131
});

pgpm/core/src/export/export-meta.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,6 @@ const config: Record<string, TableConfig> = {
114114
hash: 'uuid'
115115
}
116116
},
117-
database_extension: {
118-
schema: 'metaschema_public',
119-
table: 'database_extension',
120-
fields: {
121-
name: 'text',
122-
database_id: 'uuid'
123-
}
124-
},
125117
schema: {
126118
schema: 'metaschema_public',
127119
table: 'schema',
@@ -452,16 +444,6 @@ const config: Record<string, TableConfig> = {
452444
data: 'jsonb'
453445
}
454446
},
455-
api_extensions: {
456-
schema: 'services_public',
457-
table: 'api_extensions',
458-
fields: {
459-
id: 'uuid',
460-
database_id: 'uuid',
461-
api_id: 'uuid',
462-
schema_name: 'text'
463-
}
464-
},
465447
api_schemas: {
466448
schema: 'services_public',
467449
table: 'api_schemas',

pgpm/core/src/export/export-migrations.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ SET session_replication_role TO DEFAULT;`;
361361
// Tables that depend on 'database' being inserted first
362362
const tableOrder = [
363363
'database',
364-
'database_extension',
365364
'schema',
366365
'table',
367366
'field',
@@ -387,7 +386,6 @@ SET session_replication_role TO DEFAULT;`;
387386
'site_themes',
388387
'site_metadata',
389388
'api_modules',
390-
'api_extensions',
391389
'api_schemas',
392390
'rls_module',
393391
'user_auth_module',

0 commit comments

Comments
 (0)