SQL error: foreign key constraint fails
Last updated
Last updated
"Cannot add or update a child row: a foreign key constraint fails...."
This is a common issue with some QBCore installations. The way we set up job garages, we update the citizenid
and set it to the name of the job. Some installations prevent this due to a database constraint.
Fixing this issue is simple, just remove the constraint. Run the following SQL in your database:
Some databases might use another name than the "FK_playervehicles_players" so make sure you change it to the one showing in your error
In this example the foreign key name is player_vehicles_ibfk_1
so the sql query will look like this: