docs: correct the 1.7 account cleanup guide - #11198
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
@better-auth/api-key
better-auth
@better-auth/cimd
auth
@better-auth/core
@better-auth/drizzle-adapter
@better-auth/electron
@better-auth/expo
@better-auth/i18n
@better-auth/kysely-adapter
@better-auth/mcp
@better-auth/memory-adapter
@better-auth/mongo-adapter
@better-auth/oauth-provider
@better-auth/passkey
@better-auth/prisma-adapter
@better-auth/redis-storage
@better-auth/scim
@better-auth/sso
@better-auth/stripe
@better-auth/telemetry
@better-auth/test-utils
commit: |
|
There was a problem hiding this comment.
🟡 Changes recommended
The SQL Server example hardcodes a specific collation in an ALTER statement, which can be incorrect and unintentionally change a database’s collation during cleanup.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates the Better Auth 1.7 upgrade documentation to correct the “account issuer cleanup” steps and expand the recovery guidance for databases affected by 1.7.0–1.7.2 account identity behavior.
Changes:
- Adjusts SQL snippets to be compatible across PostgreSQL, MySQL, SQL Server, and SQLite (including quoting and SQL Server-specific syntax).
- Adds operational guidance around backups, preview-build cleanup, ORM migration application, restarts, and rollback limitations.
- Documents a recovery path for provider connections that previously collapsed into a shared Account row.
File summaries
| File | Description |
|---|---|
| docs/content/docs/guides/1-7-upgrade-guide.mdx | Refines the 1.7 issuer cleanup and recovery instructions, including per-database SQL examples and additional post-cutover verification guidance. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| ```sql | ||
| DROP INDEX account_issuer_accountId_uidx ON dbo.account; | ||
| ALTER TABLE dbo.account ALTER COLUMN issuer VARCHAR(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL; |
|
|
||
| On 1.7.0 through 1.7.2, several provider configurations could share one Account row. In 1.7.3, each provider ID needs its own row; removing the issuer column or index does not create missing accounts. Inventory those connections and their existing users before removing issuer values. | ||
|
|
||
| For affected SSO connections, configure the [user resolver](/docs/plugins/sso#resolve-sso-users) with a reviewed mapping from the configured connection, verified issuer, and subject to the existing `userId`. Return `{ action: "link", userId, profile: "preserve" }` for known mappings and reject unknown identities. The verified sign-in creates the connection's Account row for that user. Do not infer ownership from an email match or copy tokens between connections. |
There was a problem hiding this comment.
On supported deployments without native transactions or transaction async-context support, such as Cloudflare D1, configuring resolveUser as instructed returns HTTP 501 before the resolver runs. The linked SSO documentation states these requirements but provides no alternative, so affected SSO connections have no documented way to restore their missing account rows. Please document a manual or normal account-linking recovery path for deployments that cannot use the resolver.
Knowledge Base Used: Enterprise identity protocols
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/content/docs/guides/1-7-upgrade-guide.mdx">
<violation number="1" location="docs/content/docs/guides/1-7-upgrade-guide.mdx:186">
P2: This recovery path is unavailable on deployments without native transactions and transaction async-context support because `resolveUser` fails before the callback runs. Document a manual or normal account-linking recovery path for affected SSO connections on those deployments.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
|
|
||
| On 1.7.0 through 1.7.2, several provider configurations could share one Account row. In 1.7.3, each provider ID needs its own row; removing the issuer column or index does not create missing accounts. Inventory those connections and their existing users before removing issuer values. | ||
|
|
||
| For affected SSO connections, configure the [user resolver](/docs/plugins/sso#resolve-sso-users) with a reviewed mapping from the configured connection, verified issuer, and subject to the existing `userId`. Return `{ action: "link", userId, profile: "preserve" }` for known mappings and reject unknown identities. The verified sign-in creates the connection's Account row for that user. Do not infer ownership from an email match or copy tokens between connections. |
There was a problem hiding this comment.
P2: This recovery path is unavailable on deployments without native transactions and transaction async-context support because resolveUser fails before the callback runs. Document a manual or normal account-linking recovery path for affected SSO connections on those deployments.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/content/docs/guides/1-7-upgrade-guide.mdx, line 186:
<comment>This recovery path is unavailable on deployments without native transactions and transaction async-context support because `resolveUser` fails before the callback runs. Document a manual or normal account-linking recovery path for affected SSO connections on those deployments.</comment>
<file context>
@@ -150,17 +167,27 @@ Better Auth 1.7.0 through 1.7.2 added a required `issuer` column to the `account
+
+On 1.7.0 through 1.7.2, several provider configurations could share one Account row. In 1.7.3, each provider ID needs its own row; removing the issuer column or index does not create missing accounts. Inventory those connections and their existing users before removing issuer values.
+
+For affected SSO connections, configure the [user resolver](/docs/plugins/sso#resolve-sso-users) with a reviewed mapping from the configured connection, verified issuer, and subject to the existing `userId`. Return `{ action: "link", userId, profile: "preserve" }` for known mappings and reject unknown identities. The verified sign-in creates the connection's Account row for that user. Do not infer ownership from an email match or copy tokens between connections.
+
+For other providers, have the existing user authenticate with a working sign-in method and link the missing connection through the normal account-linking flow. Keep any connection without a verified recovery path disabled until its mapping is reviewed.
</file context>
| For affected SSO connections, configure the [user resolver](/docs/plugins/sso#resolve-sso-users) with a reviewed mapping from the configured connection, verified issuer, and subject to the existing `userId`. Return `{ action: "link", userId, profile: "preserve" }` for known mappings and reject unknown identities. The verified sign-in creates the connection's Account row for that user. Do not infer ownership from an email match or copy tokens between connections. | |
| For affected SSO connections on deployments with native transactions and transaction async-context support, configure the [user resolver](/docs/plugins/sso#resolve-sso-users) with a reviewed mapping from the configured connection, verified issuer, and subject to the existing `userId`. On deployments without those capabilities, document and use a manual or normal account-linking recovery path instead. |
|
|
||
| <Callout type="warn"> | ||
| Only databases that ran 1.7.0 through 1.7.2 need the steps below. New rows no longer write `issuer`, so a `NOT NULL` column rejects every sign-up and account link until you relax it. | ||
| Databases created or migrated with 1.7.0 through 1.7.2 need the cleanup below, including preview builds that stored synthetic issuers with `identityStrategy: "provider-id"`. Remove `account.identityStrategy` from preview configurations; 1.7.3 no longer supports it. A required `issuer` column rejects new account writes, and schema checks can also block existing sign-ins and session requests. |
There was a problem hiding this comment.
We don't need to mention identityStrategy. Including unreleased changes would only make this unnecessarily verbose.
bytaesu
left a comment
There was a problem hiding this comment.
I think we should keep the guide focused on what actually needs to be changed. It's enough to tell users what they need to check. Going into too detail will make it longer and more confusing.
Corrects account cleanup instructions that fail on SQL Server and PostgreSQL, and fills gaps in the 1.7.3 recovery sequence.
Summary by cubic
Corrects the 1.7 account cleanup guide so the SQL statements work on SQL Server and PostgreSQL, and completes the 1.7.3 recovery steps.
Written for commit 0b591fe. Summary will update on new commits.