Update docs to manually remove vehicle (#3075)

* Update docs to manually remove vehicle

Entry added to document how to remove a vehicle from the database until a native solution is implemented.
#3074 
#2719

* Update manually_fixing_data.mdx
This commit is contained in:
cwanja
2023-06-11 06:18:27 -05:00
committed by GitHub
parent d9da8e6fa9
commit 723b2067b3

View File

@@ -100,3 +100,23 @@ If for some reason a drive or charge was recorded incorrectly, you can delete it
</TabItem>
</Tabs>
## Remove a vehicle from the database
**NOTE:** Always [backup](https://docs.teslamate.org/docs/maintenance/backup_restore "backup") your data before performing any database changes.
1. Connect to your TeslaMate database
2. Identify the right car ID in the database to remove
```
SELECT id, vin FROM cars;
```
3. Based upon the output, run the following command replacing `num` with the ID from the previous command.
```
DELETE FROM cars WHERE id = num;
DELETE FROM car_settings WHERE id = num;
DELETE FROM charging_processes WHERE car_id = num;
DELETE from charges WHERE charging_process_id in (select id from charging_processes where car_id = num);
DELETE FROM drives WHERE car_id = num;
DELETE FROM positions WHERE car_id = num;
DELETE FROM states WHERE car_id = num;
DELETE FROM updates WHERE car_id = num;
```