MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_store_delete_project

Function cbm_store_delete_project

src/store/store.c:1734–1779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1732}
1733
1734int cbm_store_delete_project(cbm_store_t *s, const char *name) {
1735 if (!s || !s->db || !name) {
1736 return CBM_STORE_ERR;
1737 }
1738 if (exec_sql(s, "BEGIN;") != CBM_STORE_OK) {
1739 return CBM_STORE_ERR;
1740 }
1741
1742 static const char *cleanup_sql[] = {
1743 "DELETE FROM index_coverage WHERE project = ?1;",
1744 "DELETE FROM index_coverage_meta WHERE project = ?1;",
1745 "DELETE FROM projects WHERE name = ?1 || '::missed';",
1746 };
1747 for (size_t i = 0; i < sizeof(cleanup_sql) / sizeof(cleanup_sql[0]); i++) {
1748 sqlite3_stmt *cleanup = NULL;
1749 if (sqlite3_prepare_v2(s->db, cleanup_sql[i], CBM_NOT_FOUND, &cleanup, NULL) != SQLITE_OK) {
1750 store_set_error_sqlite(s, "delete project coverage prepare");
1751 (void)exec_sql(s, "ROLLBACK;");
1752 return CBM_STORE_ERR;
1753 }
1754 bind_text(cleanup, SKIP_ONE, name);
1755 int cleanup_rc = sqlite3_step(cleanup);
1756 sqlite3_finalize(cleanup);
1757 if (cleanup_rc != SQLITE_DONE) {
1758 store_set_error_sqlite(s, "delete project coverage");
1759 (void)exec_sql(s, "ROLLBACK;");
1760 return CBM_STORE_ERR;
1761 }
1762 }
1763
1764 sqlite3_stmt *stmt =
1765 prepare_cached(s, &s->stmt_delete_project, "DELETE FROM projects WHERE name = ?1;");
1766 if (!stmt) {
1767 (void)exec_sql(s, "ROLLBACK;");
1768 return CBM_STORE_ERR;
1769 }
1770
1771 bind_text(stmt, SKIP_ONE, name);
1772 int rc = sqlite3_step(stmt);
1773 if (rc != SQLITE_DONE) {
1774 store_set_error_sqlite(s, "delete_project");
1775 (void)exec_sql(s, "ROLLBACK;");
1776 return CBM_STORE_ERR;
1777 }
1778 return exec_sql(s, "COMMIT;");
1779}
1780
1781/* ── Node CRUD ──────────────────────────────────────────────────── */
1782

Callers 1

test_store_nodes.cFile · 0.85

Calls 4

exec_sqlFunction · 0.85
store_set_error_sqliteFunction · 0.85
bind_textFunction · 0.85
prepare_cachedFunction · 0.85

Tested by

no test coverage detected