ERROR: insert or update on table "vapp_vm" violates foreign key constraint "fk_vap_vm2vm" during database upgrade
book
Article ID: 408219
calendar_today
Updated On:
Products
VMware Cloud Director
Issue/Introduction
During the database upgrade of VMware Cloud Director you receive the following error...
Unable to upgrade the database: org.postgresqI.utiI.PSQLException: ERROR: insert or update on table "vapp_vm" violates foreign key constraint "fk_vap_vm2vm Detail: Key (svm_id)=(xxxx) is not present in table "vm".
Environment
9.7
10.x
Cause
This issue can occur when there is a data mismatch between the vapp_vm and vm tables in the VMware Cloud Director database, or when the vm table is missing an entry entirely.
Resolution
To remediate the issue, perform the following steps.
Remove the cloud_uuid from the VM in vCenter under Advanced Settings > Configuration Parameters. Note: Removing the cloud_uuid ensures that the VM is no longer manageable by VMware Cloud Director, which allows it to be deleted from the VMware Cloud Director UI without deleting it from vCenter.
Perform a Storage vMotion of the VM so the datastore files are updated to reflect the new VM name.