Remove player_vehicles Foreign Key Constraint
Learn how to remove the player_vehicles_ibfk_1 foreign key constraint from your MySQL database to fix vehicle insert errors for gang, job, and shared vehicles in FiveM QBCore/QBOX servers.
Overview
If your server throws this error:
Cannot add or update a child row: a foreign key constraint fails
(`otherplanet_server`.`player_vehicles`, CONSTRAINT `player_vehicles_ibfk_1`
FOREIGN KEY (`citizenid`) REFERENCES `players` (`citizenid`)
ON DELETE CASCADE ON UPDATE CASCADE)It means the player_vehicles table has a foreign key constraint linked to the players table.
When a vehicle is inserted for a player that does not exist in players, MySQL blocks the insert.
Goal
Remove the constraint:
player_vehicles_ibfk_1So vehicles can be inserted without checking players.citizenid.
Step 1 - Open Your Database
Use one of these:
phpMyAdmin
HeidiSQL
DBeaver
Navicat
MySQL CLI
Step 2 - Remove the Constraint
Run:
Last updated