# 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;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.otherplanet.dev/scripts/op-gangs/tutorials/remove-player_vehicles-foreign-key-constraint.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
