> For the complete documentation index, see [llms.txt](https://docs.otherplanet.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.otherplanet.dev/scripts/op-gangs/tutorials/remove-player_vehicles-foreign-key-constraint.md).

# Remove player\_vehicles Foreign Key Constraint

## Overview

If your server throws this error:

```luau
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_1
```

So 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:

```
ALTER TABLE player_vehicles
DROP FOREIGN KEY player_vehicles_ibfk_1;
```
