Skip to content

feat: adapt audit schema to query-lib Attribute and Index VOs - #133

Open
abnegate wants to merge 12 commits into
mainfrom
feat-query-lib
Open

feat: adapt audit schema to query-lib Attribute and Index VOs#133
abnegate wants to merge 12 commits into
mainfrom
feat-query-lib

Conversation

@abnegate

@abnegate abnegate commented Aug 21, 2026

Copy link
Copy Markdown
Member

Adapts the audit schema to the query-lib Attribute and Index value objects.

Why this approach

Database::createCollection() takes a Collection only, so audit setup now passes new Collection(id:, attributes:, indexes:) built from the typed Attribute and Index factories instead of raw arrays and Database::VAR_* strings.

The audit schema itself is unchanged.

utopia-php/database is pinned to dev-feat-query-lib as 7.0.0, re-pinned to that branch's head whenever it moves.

Chain

Landing order, bottom up:

  1. utopia-php/database#823 — the query-lib migration itself
  2. utopia-php/abuse#124, utopia-php/audit#133, utopia-php/migration#222 — the schema call sites in the libraries
  3. appwrite/appwrite#11649
  4. appwrite-labs/cloud#5410

Stacked on #823 but not part of it, and not required by anything above: #947 (ORM), #948 (repositories and seeding), #949 (migration runner and schema differ).

Every dev-feat-query-lib pin in this train is re-pinned to its branch head whenever one of them moves, so each PR's CI runs against what the others actually contain.

Verified

  • CI green on this head
  • Greptile 5/5, no unresolved threads
  • Pint on the Collection wrap

Not verified

  • The utopia-php/database dependency is still a branch pin. It becomes a released tag only once #823 merges, and this PR should not land before that.

Needed so Appwrite can take main's queue 1.3 pin.
Take main's validators ^0.5 pin and refresh database feat-query-lib so Attribute/Index/ColumnType stay current.
ClickHouse was mutating parent Attribute/Index instances in place.
MariaDB tests were also losing event=delete rows because persistent
PDO plus a new adapter per PHPUnit setUp rolled back uncommitted writes.
@github-actions

Copy link
Copy Markdown

Thanks for contributing! This repository is a read-only mirror; development for this library happens in packages/audit in the utopia-php monorepo. Please open this pull request there instead.

@github-actions github-actions Bot closed this Aug 21, 2026
@abnegate abnegate reopened this Aug 21, 2026
@abnegate

Copy link
Copy Markdown
Member Author

@greptile-apps review

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown

Greptile Summary

The PR migrates audit schema declarations to the query-lib Attribute, Index, and Collection value objects.

  • Replaces raw shared and ClickHouse schema arrays with typed value objects.
  • Updates relational collection creation and schema-oriented tests for the new API.
  • Pins the database migration branch and updates the resolved dependency graph.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains within the eligible follow-up review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
src/Audit/Adapter/SQL.php Replaces shared raw attribute and index definitions with typed value-object factories.
src/Audit/Adapter/Database.php Passes a typed Collection into database setup and adopts property access for schema metadata.
src/Audit/Adapter/ClickHouse.php Migrates ClickHouse-specific schema declarations and selected metadata consumers to typed value objects.
composer.json Pins the query-lib database branch, updates validators, and registers required VCS repositories.
tests/Audit/Adapter/ClickHouseTest.php Updates schema assertions to inspect typed Attribute and Index objects.
tests/Audit/Adapter/DatabaseTest.php Disables persistent PDO connections in the relational adapter test setup.

Reviews (10): Last reviewed commit: "chore(deps): require validators ^0.6" | Re-trigger Greptile

Schema definitions with a known column or index type now use
Attribute::string() / Index::key() instead of the generic
constructors plus ColumnType / IndexType.
Asterisk wildcards on utopia-php packages are replaced with
equivalent caret constraints so Composer ranges stay consistent.
Keep composer.json and composer.lock in sync so `composer validate`
passes, and pin utopia-php/database to the current query-lib HEAD.
@abnegate

Copy link
Copy Markdown
Member Author

@greptileai review

@abnegate

Copy link
Copy Markdown
Member Author

@greptile-apps review

Force re-review of HEAD 348a4f8. Description updated for factories and caret lock refresh.

abnegate and others added 4 commits August 21, 2026 18:52
Database::createCollection no longer accepts a string id.
Database feat-query-lib now requires query ^0.5 after nested joins.
main's #91 migrated the ClickHouse adapter onto the query library's own
builder and schema and moved to query 0.6, which is strictly ahead of the
hand-rolled SQL this branch carried. That side is taken wholesale: the
builder, the schema, the SQL snapshot test, Query.php and the 0.6
constraint are all main's.

What main does not have is the database 7 adaptation, which is the reason
this branch exists. Released database 7.2.2 still takes
createCollection(string, array, array) and still exposes VAR_STRING,
INDEX_KEY and VAR_DATETIME; the dev branch behind PR #823 replaces all of
that with Collection, Attribute and Index value objects and drops the
constants. main's ClickHouse.php therefore does not load against it -- 48
PHPStan errors, all undefined constants.

So getAttributes() and getIndexes() are ported onto main's file as value
objects, and the three consumers that still read $attribute['type'] and
$attribute['required'] now read the properties. The port is
attribute-for-attribute equal: all 35 columns match on type and required,
and Attribute::string() defaults size to Database::LENGTH_KEY, which is
what the raw arrays passed. The eight indexes map onto Index::key(), which
is the same type/lengths/orders triple.

Three of main's ClickHouse tests asserted the array shape and now assert
the value objects.

database is pinned to dev-feat-query-lib as 7.0.0 with the VCS
repositories, matching abuse#124 and migration#222. All four pins come off
together when database 8 is tagged.

Verified against the real backends: PHPStan clean, 22 unit tests, 91 e2e
tests with 979 assertions.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
utopia-php/database#823 moved its ORM, repository/seeder and migration-runner
layers into stacked PRs, so its branch head moved. Nothing here referenced any
of them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
utopia-php/database moved to ^0.6 and appwrite/appwrite followed on main, so a
consumer that pins both cannot resolve while this one still asks for ^0.5:

    utopia-php/audit dev-feat-query-lib requires utopia-php/validators ^0.5
    -> found 0.5.0 but it conflicts with your root composer.json require (^0.6)

Also re-pins the database lock to the current chain head.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant