Skip to main content
Glama
dbschemadiff.ts1.43 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { allOk, FileBuilder } from '@medplum/core'; import type { FhirRequest, FhirResponse } from '@medplum/fhir-router'; import type { OperationDefinition } from '@medplum/fhirtypes'; import { requireSuperAdmin } from '../../admin/super'; import { DatabaseMode, getDatabasePool } from '../../database'; import { buildMigration } from '../../migrations/migrate'; import { buildOutputParameters } from './utils/parameters'; const operation: OperationDefinition = { resourceType: 'OperationDefinition', name: 'db-schema-diff', status: 'active', kind: 'operation', code: 'schema-diff', experimental: true, system: true, type: false, instance: false, parameter: [ { use: 'out', name: 'migrationString', type: 'string', min: 1, max: '1', }, ], }; export async function dbSchemaDiffHandler(_req: FhirRequest): Promise<FhirResponse> { requireSuperAdmin(); const dbClient = getDatabasePool(DatabaseMode.READER); const b = new FileBuilder(' ', false); b.append('// The schema migration needed to match the expected schema'); b.append(''); await buildMigration(b, { dbClient, dropUnmatchedIndexes: true, allowPostDeployActions: true, }); return [allOk, buildOutputParameters(operation, { migrationString: b.toString() })]; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/medplum/medplum'

If you have feedback or need assistance with the MCP directory API, please join our Discord server