[PR #7492] [CLOSED] fix: postgres escaped search_path #24252

Closed
opened 2026-04-15 22:15:41 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7492
Author: @Diabl0570
Created: 1/20/2026
Status: Closed

Base: canaryHead: fix/postgres-escaped-search-path


📝 Commits (1)

  • e112fc5 fix: postgres escaped search_path

📊 Changes

1 file changed (+2 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/db/get-migration.ts (+2 -2)

📄 Description

Problem

When running migrations on PostgreSQL, users could see the following warning:

Schema '\$user' does not exist. Tables will be inspected from available schemas.

Even tho I am sure the schema exists for $user

Cause

PostgreSQL's search_path can return the $user variable in different formats:

  • $user (unescaped) - standard PostgreSQL default
  • \$user (escaped) - used by some providers like Supabase

Summary by cubic

Fixed PostgreSQL schema detection when providers escape $user in search_path, preventing false warnings and correctly choosing the next valid schema (e.g., public).

  • Bug Fixes
    • Filter both user and \$user with a regex that matches an optional backslash before .
    • Removes the "Schema '$user' does not exist" warning in migrations; compatible with Supabase’s escaped search_path (https://github.com/supabase/supabase/issues/20842).

Written for commit ac0cb53ec0. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7492 **Author:** [@Diabl0570](https://github.com/Diabl0570) **Created:** 1/20/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/postgres-escaped-search-path` --- ### 📝 Commits (1) - [`e112fc5`](https://github.com/better-auth/better-auth/commit/e112fc5f4adeefb8b516b9e2663fd14cc91256b7) fix: postgres escaped search_path ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/get-migration.ts` (+2 -2) </details> ### 📄 Description ### Problem When running migrations on PostgreSQL, users could see the following warning: ``` Schema '\$user' does not exist. Tables will be inspected from available schemas. ``` Even tho I am sure the schema exists for `$user` ### Cause PostgreSQL's `search_path` can return the `$user` variable in different formats: - `$user` (unescaped) - standard PostgreSQL default - `\$user` (escaped) - used by some providers like Supabase <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed PostgreSQL schema detection when providers escape $user in search_path, preventing false warnings and correctly choosing the next valid schema (e.g., public). - **Bug Fixes** - Filter both $user and \$user with a regex that matches an optional backslash before $. - Removes the "Schema '\$user' does not exist" warning in migrations; compatible with Supabase’s escaped search_path (https://github.com/supabase/supabase/issues/20842). <sup>Written for commit ac0cb53ec02c9802ceb674f64821662656287f35. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:15:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#24252