chore: drop location column and parse N-part resource paths#118
Conversation
Removes the unused `location` column from the audit schema. The cloud audit pipeline resolves country at write time instead, and no consumer relies on the legacy `location` field. Generalizes `SQL::parseResource()` to handle any even number of segments shaped as alternating `<type>/<id>`. Previously only 2-part and 4-part paths were parsed; 6-part paths like `database/<id>/collection/<id>/document/<id>` fell through to the default fallback, leaving `resourceType` and `resourceParent` empty. Breaking change: `Audit::log()` no longer accepts the `$location` positional parameter; the `location` key is removed from the create / createBatch log shape and from `Log::getLocation()`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Greptile SummaryThis PR removes the
Confidence Score: 5/5Safe to merge; the logic changes are well-scoped and consistent across the codebase. The No files require special attention; downstream callers and DB migration noted in the PR description are outside this repository's scope. Important Files Changed
Reviews (3): Last reviewed commit: "test: cover country via getRequiredAttri..." | Re-trigger Greptile |
Country is now resolved at write time by callers (the cloud audit worker resolves the lowercase ISO 3166-1 alpha-2 code from IP via geodb) and supplied through the log data array. Adds a round-trip test covering Audit::log(), Audit::logBatch(), and the no-country fallback. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…test Country is a ClickHouse-only schema column (the SQL/Database adapter has no country column — country lives inside the JSON data column there). Adding `country` to ClickHouseTest::getRequiredAttributes() makes every AuditBase test that creates logs against ClickHouse pass the value through the data array, where the adapter then extracts it to the schema column. Same pattern already in use for resourceType, resourceId, projectId, and friends. Drops the dedicated testCountryRoundTrip in favor of this implicit coverage. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
locationcolumn from the audit schema. Country is now resolved at write time in the consuming worker (cloud'sActivityaudit override populatescountryvia geodb), and no remaining consumer needslocation. Breaking change for callers that still pass it.SQL::parseResource()to handle any even number of segments shaped as alternating<type>/<id>. Previously only 2-part and 4-part paths were parsed; 6-part paths likedatabase/<dbId>/collection/<colId>/document/<docId>fell through to the default fallback, leavingresourceTypeandresourceParentempty in stored audit rows.Resource parsing rule
For an input split on
/intoNsegments:N == 0orNis odd →resourceId = $resource(whole string),resourceType = '',resourceParent = ''.N == 2→resourceType = parts[0],resourceId = parts[1],resourceParent = ''.N == 4, 6, 8, ...(even) →resourceId = parts[N-1],resourceType = parts[N-2],resourceParent = implode('/', parts[0..N-3]).Breaking changes
Audit::log()signature loses thestring $locationpositional parameter. Move callers fromlog(..., \$ip, \$location, \$data)tolog(..., \$ip, \$data).Adapter::create()/Adapter::createBatch()array shapes no longer accept alocationkey.Log::getLocation()is removed.locationcolumn is dropped fromSQL::getAttributes()(downstream ClickHouse / Database schemas should run a migration to drop the column).Test plan
composer lint(Pint, pass)composer check(PHPStan level max, pass)testParseResourceMethodcovers the new 6-part / 2-part / odd-part cases.\$locationtoAudit::log().🤖 Generated with Claude Code