GitHub user dosubot[bot] added a comment to the discussion: What is the safest 
way to delete all records from DB of a certain project?

<!-- Greeting -->
Hi @segovend! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the 
incubator-devlake team.

<!-- Answer -->
The safest way to delete all records for a specific project—including raw 
data—in DevLake is to use the built-in API endpoint for project deletion. This 
endpoint (`DELETE /projects/:projectName`) calls a service-layer function that 
handles the removal of the project and all associated data, ensuring 
dependencies and related records are properly managed. This approach is much 
safer than running manual SQL queries, as it helps prevent orphaned data and 
maintains referential integrity throughout the database. You can see the 
relevant implementation and details 
[here](https://github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/backend/server/api/project/project.go).

There is no official, single SQL script provided for this operation, and direct 
SQL deletion is discouraged due to the complexity of relationships between 
tables. If you use the API, make sure to back up your database first and verify 
that the deletion resolves your pipeline issues.

Note: There is a known bug with Jira data where some records might remain in 
the domain layer even after deletion, due to how certain raw data tables are 
referenced. If you suspect lingering Jira data, you may need to manually verify 
or clean up those tables. More details on this bug and its proposed fix can be 
found [here](https://github.com/apache/incubator-devlake/issues/8330).


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/79374413-41df-42b6-a489-8104eb547073?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/79374413-41df-42b6-a489-8104eb547073?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/79374413-41df-42b6-a489-8104eb547073?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/79374413-41df-42b6-a489-8104eb547073?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/79374413-41df-42b6-a489-8104eb547073?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/79374413-41df-42b6-a489-8104eb547073?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/79374413-41df-42b6-a489-8104eb547073?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat
 with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/b4e8e847-d479-4541-83a8-d88d83fea5c9/ask?utm_source=github)&
 nbsp;[![Join 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/incubator-devlake/discussions/8597)

GitHub link: 
https://github.com/apache/incubator-devlake/discussions/8597#discussioncomment-14563389

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to