Repository navigation
Added Ghost-specific Knex adapter tests for Better Auth - #32615
Conversation
ref https://linear.app/ghost/issue/PLA-597/get-the-knex-adapter-suite-green-on-mysql-in-ci Better Auth's adapter suite can't cover the parts of the adapter that only exist because of Ghost's schema: the virtual email_verified and two_factor_enabled columns, the users create defaults, and millisecond dates on the new tables. These tests pin that behaviour against Ghost's real test database, so the virtual columns are proven before plan §10 open decision 1 is settled. user_two_factors becomes an in-development table rather than something the test builds itself, so two_factor_enabled is tested against the definition the twoFactor plugin will use. It holds TOTP secrets and backup codes, so it is left out of exports by default like the other auth tables.
|
No actionable comments were generated in the recent review. WalkthroughThe schema adds Possibly related PRs
Suggested reviewers: Merge Risk:
|
|
It looks like this PR contains a migration 👀 General requirements
Schema changes
Data changes
|
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run ghost:test:ci:integration |
✅ Succeeded | 2m 55s | View ↗ |
nx run ghost:test:integration |
✅ Succeeded | 2m 16s | View ↗ |
nx run ghost:test:bullmq:scenarios |
✅ Succeeded | 59s | View ↗ |
nx run ghost:test:bullmq |
✅ Succeeded | 52s | View ↗ |
nx run ghost:test:ci:e2e |
✅ Succeeded | 5m 52s | View ↗ |
nx run ghost:test:e2e |
✅ Succeeded | 4m 1s | View ↗ |
nx run ghost:test:ci:unit |
✅ Succeeded | 1m 32s | View ↗ |
nx run ghost:test:legacy |
✅ Succeeded | 1m 38s | View ↗ |
Additional runs (8) |
✅ Succeeded | ... | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-11-05 22:04:18 UTC
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #32615 +/- ##
==========================================
+ Coverage 85.77% 85.93% +0.15%
==========================================
Files 1416 1416
Lines 53885 53885
Branches 9304 9304
==========================================
+ Hits 46219 46304 +85
+ Misses 6514 6434 -80
+ Partials 1152 1147 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|

ref https://linear.app/ghost/issue/PLA-597/get-the-knex-adapter-suite-green-on-mysql-in-ci
Better Auth's adapter suite already runs on MySQL in the integration lane, but it can't cover behaviour that only exists because of Ghost's schema. This adds
test/integration/auth/knex-adapter-ghost.test.ts, which runs against Ghost's real test database:email_verified: readstruefor every user, filters on the expression, and writes of either value are dropped without error.two_factor_enabled:trueonly with a verifieduser_two_factorsrow. No row, or only an unverified one, readsfalse. Writes are dropped. Fields come fromghostTwoFactorSchema.createDefaults: a user created through Better Auth getsslugset to its id andpasswordset to!, and@tryghost/security's compare rejects that hash.user_sessions,user_accountsandverificationskeep their milliseconds through the adapter and in the stored row.user_two_factorsbecomes an in-development table inschema.js, so it only exists in development and testing databases and has no migration. That way the test checkstwo_factor_enabledagainst the table definition thetwoFactorplugin will use, rather than one the test builds for itself. The table holds TOTP secrets and backup codes, so it's added to the exporter'sBACKUP_TABLESand stays out of exports by default, like the other auth tables.For reviewers:
userscolumns) isn't needed.user_two_factorshas no unique key onuser_idand no index onsecret(the plugin markssecretas indexed, but it's a text column).Run locally on MySQL 8, all passing: the auth integration tests (482 passed, the suite's usual 15 skips), the exporter and migration integration tests, and the schema and exporter unit tests.
🤖 Generated with Claude Code