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

Function cbm_store_delete_project

src/store/store.c:1732–1777  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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