Commit 6aa19a3
authored
feat(db): implement P0 database TODOs - issue deps & audit logging (#216)
* feat(db): implement P0 database TODOs - issue deps & audit logging (#207)
Completes high-priority database integration items:
Issue Dependency Parsing:
- Add depends_on TEXT column to issues table schema
- Parse depends_on JSON field in get_issues_with_tasks()
- Handle NULL, invalid JSON, and non-list values gracefully
- Add depends_on to ALLOWED_ISSUE_FIELDS whitelist
- Add migration support for existing databases
Project Audit Logging:
- Add user_id and ip_address params to update_project()
- Add user_id and ip_address params to delete_project()
- Log PROJECT_UPDATED event with updated_fields metadata
- Log PROJECT_DELETED event with project name preservation
- Skip audit logging for system operations (no user_id)
Tests:
- 16 TDD tests covering all new functionality
- Verified 72 existing tests still pass (backward compatible)
* refactor(db): address code review feedback for database TODOs
Security:
- Add SQL identifier validation in _add_column_if_not_exists() to prevent
SQL injection (validates alphanumeric + underscore pattern)
Code Quality:
- Extract _parse_depends_on() helper method for centralized JSON parsing
- Document local imports explaining circular dependency avoidance
- Document audit logging transaction behavior (data consistency over audit)
All 16 tests still passing.
* fix(db): ensure type consistency and audit gating
- _parse_depends_on: Coerce JSON values to strings for consistent API contract
(json.loads may return ints, but callers expect List[str])
- delete_project: Only emit PROJECT_DELETED audit when rows_affected > 0
(mirrors update_project behavior, avoids logging no-op deletions)1 parent 8e279ab commit 6aa19a3
File tree
4 files changed
+591
-11
lines changed- codeframe/persistence
- repositories
- tests/persistence
4 files changed
+591
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
157 | 161 | | |
158 | 162 | | |
159 | 163 | | |
| |||
162 | 166 | | |
163 | 167 | | |
164 | 168 | | |
165 | | - | |
| 169 | + | |
166 | 170 | | |
167 | 171 | | |
168 | 172 | | |
| |||
306 | 310 | | |
307 | 311 | | |
308 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
309 | 340 | | |
310 | 341 | | |
311 | 342 | | |
| |||
Lines changed: 61 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
195 | 201 | | |
196 | 202 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | 203 | | |
201 | 204 | | |
202 | 205 | | |
| 206 | + | |
| 207 | + | |
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
| |||
238 | 243 | | |
239 | 244 | | |
240 | 245 | | |
241 | | - | |
| 246 | + | |
242 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
243 | 263 | | |
| 264 | + | |
244 | 265 | | |
245 | | - | |
246 | | - | |
247 | 266 | | |
248 | | - | |
249 | | - | |
250 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
251 | 275 | | |
252 | 276 | | |
253 | 277 | | |
| 278 | + | |
| 279 | + | |
254 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
255 | 288 | | |
256 | 289 | | |
257 | 290 | | |
258 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
259 | 310 | | |
260 | 311 | | |
261 | 312 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
71 | 129 | | |
72 | 130 | | |
73 | 131 | | |
| |||
198 | 256 | | |
199 | 257 | | |
200 | 258 | | |
| 259 | + | |
201 | 260 | | |
202 | 261 | | |
203 | 262 | | |
| |||
0 commit comments