// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
// SPDX-License-Identifier: Apache-2.0
import type { PoolClient } from 'pg';
import { prepareCustomMigrationJobData, runCustomMigration } from '../../workers/post-deploy-migration';
import * as fns from '../migrate-functions';
import type { MigrationActionResult } from '../types';
import type { CustomPostDeployMigration } from './types';
export const migration: CustomPostDeployMigration = {
type: 'custom',
prepareJobData: (asyncJob) => prepareCustomMigrationJobData(asyncJob),
run: async (repo, job, jobData) => runCustomMigration(repo, job, jobData, callback),
};
// prettier-ignore
async function callback(client: PoolClient, results: MigrationActionResult[]): Promise<void> {
await fns.analyzeTable(client, results, 'Account');
await fns.analyzeTable(client, results, 'ActivityDefinition');
await fns.analyzeTable(client, results, 'AdverseEvent');
await fns.analyzeTable(client, results, 'AllergyIntolerance');
await fns.analyzeTable(client, results, 'Appointment');
await fns.analyzeTable(client, results, 'AppointmentResponse');
await fns.analyzeTable(client, results, 'AuditEvent');
await fns.analyzeTable(client, results, 'Basic');
await fns.analyzeTable(client, results, 'Binary');
await fns.analyzeTable(client, results, 'BiologicallyDerivedProduct');
await fns.analyzeTable(client, results, 'BodyStructure');
await fns.analyzeTable(client, results, 'Bundle');
await fns.analyzeTable(client, results, 'CapabilityStatement');
await fns.analyzeTable(client, results, 'CarePlan');
await fns.analyzeTable(client, results, 'CareTeam');
await fns.analyzeTable(client, results, 'CatalogEntry');
await fns.analyzeTable(client, results, 'ChargeItem');
await fns.analyzeTable(client, results, 'ChargeItemDefinition');
await fns.analyzeTable(client, results, 'Claim');
await fns.analyzeTable(client, results, 'ClaimResponse');
await fns.analyzeTable(client, results, 'ClinicalImpression');
await fns.analyzeTable(client, results, 'CodeSystem');
await fns.analyzeTable(client, results, 'Communication');
await fns.analyzeTable(client, results, 'CommunicationRequest');
await fns.analyzeTable(client, results, 'CompartmentDefinition');
await fns.analyzeTable(client, results, 'Composition');
await fns.analyzeTable(client, results, 'ConceptMap');
await fns.analyzeTable(client, results, 'Condition');
await fns.analyzeTable(client, results, 'Consent');
await fns.analyzeTable(client, results, 'Contract');
await fns.analyzeTable(client, results, 'Coverage');
await fns.analyzeTable(client, results, 'CoverageEligibilityRequest');
await fns.analyzeTable(client, results, 'CoverageEligibilityResponse');
await fns.analyzeTable(client, results, 'DetectedIssue');
await fns.analyzeTable(client, results, 'Device');
await fns.analyzeTable(client, results, 'DeviceDefinition');
await fns.analyzeTable(client, results, 'DeviceMetric');
await fns.analyzeTable(client, results, 'DeviceRequest');
await fns.analyzeTable(client, results, 'DeviceUseStatement');
await fns.analyzeTable(client, results, 'DiagnosticReport');
await fns.analyzeTable(client, results, 'DocumentManifest');
await fns.analyzeTable(client, results, 'DocumentReference');
await fns.analyzeTable(client, results, 'EffectEvidenceSynthesis');
await fns.analyzeTable(client, results, 'Encounter');
await fns.analyzeTable(client, results, 'Endpoint');
await fns.analyzeTable(client, results, 'EnrollmentRequest');
await fns.analyzeTable(client, results, 'EnrollmentResponse');
await fns.analyzeTable(client, results, 'EpisodeOfCare');
await fns.analyzeTable(client, results, 'EventDefinition');
await fns.analyzeTable(client, results, 'Evidence');
await fns.analyzeTable(client, results, 'EvidenceVariable');
await fns.analyzeTable(client, results, 'ExampleScenario');
await fns.analyzeTable(client, results, 'ExplanationOfBenefit');
await fns.analyzeTable(client, results, 'FamilyMemberHistory');
await fns.analyzeTable(client, results, 'Flag');
await fns.analyzeTable(client, results, 'Goal');
await fns.analyzeTable(client, results, 'GraphDefinition');
await fns.analyzeTable(client, results, 'Group');
await fns.analyzeTable(client, results, 'GuidanceResponse');
await fns.analyzeTable(client, results, 'HealthcareService');
await fns.analyzeTable(client, results, 'ImagingStudy');
await fns.analyzeTable(client, results, 'Immunization');
await fns.analyzeTable(client, results, 'ImmunizationEvaluation');
await fns.analyzeTable(client, results, 'ImmunizationRecommendation');
await fns.analyzeTable(client, results, 'ImplementationGuide');
await fns.analyzeTable(client, results, 'InsurancePlan');
await fns.analyzeTable(client, results, 'Invoice');
await fns.analyzeTable(client, results, 'Library');
await fns.analyzeTable(client, results, 'Linkage');
await fns.analyzeTable(client, results, 'List');
await fns.analyzeTable(client, results, 'Location');
await fns.analyzeTable(client, results, 'Measure');
await fns.analyzeTable(client, results, 'MeasureReport');
await fns.analyzeTable(client, results, 'Media');
await fns.analyzeTable(client, results, 'Medication');
await fns.analyzeTable(client, results, 'MedicationAdministration');
await fns.analyzeTable(client, results, 'MedicationDispense');
await fns.analyzeTable(client, results, 'MedicationKnowledge');
await fns.analyzeTable(client, results, 'MedicationRequest');
await fns.analyzeTable(client, results, 'MedicationStatement');
await fns.analyzeTable(client, results, 'MedicinalProduct');
await fns.analyzeTable(client, results, 'MedicinalProductAuthorization');
await fns.analyzeTable(client, results, 'MedicinalProductContraindication');
await fns.analyzeTable(client, results, 'MedicinalProductIndication');
await fns.analyzeTable(client, results, 'MedicinalProductIngredient');
await fns.analyzeTable(client, results, 'MedicinalProductInteraction');
await fns.analyzeTable(client, results, 'MedicinalProductManufactured');
await fns.analyzeTable(client, results, 'MedicinalProductPackaged');
await fns.analyzeTable(client, results, 'MedicinalProductPharmaceutical');
await fns.analyzeTable(client, results, 'MedicinalProductUndesirableEffect');
await fns.analyzeTable(client, results, 'MessageDefinition');
await fns.analyzeTable(client, results, 'MessageHeader');
await fns.analyzeTable(client, results, 'MolecularSequence');
await fns.analyzeTable(client, results, 'NamingSystem');
await fns.analyzeTable(client, results, 'NutritionOrder');
await fns.analyzeTable(client, results, 'Observation');
await fns.analyzeTable(client, results, 'ObservationDefinition');
await fns.analyzeTable(client, results, 'OperationDefinition');
await fns.analyzeTable(client, results, 'OperationOutcome');
await fns.analyzeTable(client, results, 'Organization');
await fns.analyzeTable(client, results, 'OrganizationAffiliation');
await fns.analyzeTable(client, results, 'Parameters');
await fns.analyzeTable(client, results, 'Patient');
await fns.analyzeTable(client, results, 'PaymentNotice');
await fns.analyzeTable(client, results, 'PaymentReconciliation');
await fns.analyzeTable(client, results, 'Person');
await fns.analyzeTable(client, results, 'PlanDefinition');
await fns.analyzeTable(client, results, 'Practitioner');
await fns.analyzeTable(client, results, 'PractitionerRole');
await fns.analyzeTable(client, results, 'Procedure');
await fns.analyzeTable(client, results, 'Provenance');
await fns.analyzeTable(client, results, 'Questionnaire');
await fns.analyzeTable(client, results, 'QuestionnaireResponse');
await fns.analyzeTable(client, results, 'RelatedPerson');
await fns.analyzeTable(client, results, 'RequestGroup');
await fns.analyzeTable(client, results, 'ResearchDefinition');
await fns.analyzeTable(client, results, 'ResearchElementDefinition');
await fns.analyzeTable(client, results, 'ResearchStudy');
await fns.analyzeTable(client, results, 'ResearchSubject');
await fns.analyzeTable(client, results, 'RiskAssessment');
await fns.analyzeTable(client, results, 'RiskEvidenceSynthesis');
await fns.analyzeTable(client, results, 'Schedule');
await fns.analyzeTable(client, results, 'SearchParameter');
await fns.analyzeTable(client, results, 'ServiceRequest');
await fns.analyzeTable(client, results, 'Slot');
await fns.analyzeTable(client, results, 'Specimen');
await fns.analyzeTable(client, results, 'SpecimenDefinition');
await fns.analyzeTable(client, results, 'StructureDefinition');
await fns.analyzeTable(client, results, 'StructureMap');
await fns.analyzeTable(client, results, 'Subscription');
await fns.analyzeTable(client, results, 'SubscriptionStatus');
await fns.analyzeTable(client, results, 'Substance');
await fns.analyzeTable(client, results, 'SubstanceNucleicAcid');
await fns.analyzeTable(client, results, 'SubstancePolymer');
await fns.analyzeTable(client, results, 'SubstanceProtein');
await fns.analyzeTable(client, results, 'SubstanceReferenceInformation');
await fns.analyzeTable(client, results, 'SubstanceSourceMaterial');
await fns.analyzeTable(client, results, 'SubstanceSpecification');
await fns.analyzeTable(client, results, 'SupplyDelivery');
await fns.analyzeTable(client, results, 'SupplyRequest');
await fns.analyzeTable(client, results, 'Task');
await fns.analyzeTable(client, results, 'TerminologyCapabilities');
await fns.analyzeTable(client, results, 'TestReport');
await fns.analyzeTable(client, results, 'TestScript');
await fns.analyzeTable(client, results, 'ValueSet');
await fns.analyzeTable(client, results, 'VerificationResult');
await fns.analyzeTable(client, results, 'VisionPrescription');
await fns.analyzeTable(client, results, 'Project');
await fns.analyzeTable(client, results, 'ClientApplication');
await fns.analyzeTable(client, results, 'User');
await fns.analyzeTable(client, results, 'ProjectMembership');
await fns.analyzeTable(client, results, 'Bot');
await fns.analyzeTable(client, results, 'Login');
await fns.analyzeTable(client, results, 'PasswordChangeRequest');
await fns.analyzeTable(client, results, 'UserSecurityRequest');
await fns.analyzeTable(client, results, 'JsonWebKey');
await fns.analyzeTable(client, results, 'AccessPolicy');
await fns.analyzeTable(client, results, 'UserConfiguration');
await fns.analyzeTable(client, results, 'BulkDataExport');
await fns.analyzeTable(client, results, 'SmartAppLaunch');
await fns.analyzeTable(client, results, 'DomainConfiguration');
await fns.analyzeTable(client, results, 'AsyncJob');
await fns.analyzeTable(client, results, 'Agent');
}