Skip to content

feat: change pg_authid 2 pg_roles - #302

Merged
soedirgo merged 1 commit into
supabase:masterfrom
fuergaosi233:master
Jul 21, 2022
Merged

soedirgo merged 1 commit into
supabase:masterfrom
fuergaosi233:master

Conversation

@fuergaosi233

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug Fix

What is the current behavior?

Please link any relevant issues here.

What is the new behavior?

Change the use of pg_authid to pg_roles

@fuergaosi233
fuergaosi233 requested a review from a team as a code owner July 20, 2022 18:37

@soedirgo soedirgo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@soedirgo soedirgo linked an issue Jul 21, 2022 that may be closed by this pull request
@soedirgo
soedirgo merged commit e5e7a82 into supabase:master Jul 21, 2022
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.41.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@fuergaosi233

Copy link
Copy Markdown
Contributor Author

Thanks!
How do I trigger a Docker image build? I need to update Supabase's Docker-compose configuration.

avallete pushed a commit that referenced this pull request Jun 20, 2026
The package isn't published to npm yet; pin the dependency to the
pkg.pr.new preview build for pg-toolbelt PR #302 so CI can install it.
The lockfile must be regenerated (`npm install`) in an environment with
network access to pkg.pr.new — the remote sandbox's egress allowlist
blocks that host.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B53a2ayu9d16u821FQ5Qqz
avallete added a commit that referenced this pull request Aug 31, 2026
* feat: consume @supabase/postgrest-typegen for type generation

Integrate the extracted @supabase/postgrest-typegen package as the single
source of truth for type generation, replacing the embedded templates.

- src/lib/generators.ts: rewrite getGeneratorMetadata as a ~30-line adapter
  over the package's introspect(). It wraps pgMeta.query into the package's
  structural Queryable (throws on {error}), preserves the
  Promise<PostgresMetaResult<GeneratorMetadata>> contract, surfaces the first
  query error, and still ends the pool. Re-exports GeneratorMetadata from the
  package.
- src/server/server.ts: getTypeOutput now calls getGeneratorMetadata +
  generateTypescript/Go/Python/Swift, threading GENERATE_TYPES_DEFAULT_SCHEMA,
  POSTGREST_VERSION, detect-1:1, and Swift access-control env values. Behavior
  freeze: the CLI path still only supports included schemas.
- src/server/routes/generators/*.ts: swap `apply` template imports for the
  package's generateX; query params, headers, and error shapes unchanged.
- Delete src/server/templates/*.ts and test/server/templates/go.test.ts;
  re-point test/types.test.ts's pgTypeToTsType import and constants.ts's
  AccessControl import to the package; drop the now-unused VALID_* constants.
- Keep PostgresMetaRelationships.ts and src/lib/sql/*.sql.ts (they back the
  REST endpoints) — accepted temporary duplication.

`npm run check` passes. Full-suite byte-parity validation is Phase 2.3
(PGMETA-114). The dependency is pinned to 1.0.0-alpha.1; local validation
installs it from Verdaccio via an uncommitted scoped .npmrc, and the lockfile
is finalized when the package is published to npm (Phase 3).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B53a2ayu9d16u821FQ5Qqz

* chore: point @supabase/postgrest-typegen at pkg-pr-new preview build

The package isn't published to npm yet; pin the dependency to the
pkg.pr.new preview build for pg-toolbelt PR #302 so CI can install it.
The lockfile must be regenerated (`npm install`) in an environment with
network access to pkg.pr.new — the remote sandbox's egress allowlist
blocks that host.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B53a2ayu9d16u821FQ5Qqz

* chore: update lockfile for postgrest-typegen pkg-pr-new build

* fix: sort generator metadata for deterministic type generation

The Go/Python/Swift generators emit objects in GeneratorMetadata order, so
output depended on the order introspection returned rows (environment-dependent
heap order). Apply the package's new sortGeneratorMetadata pass in the
getGeneratorMetadata adapter so all four generators receive canonically-ordered
metadata.

Regenerate the typegen go/python snapshots accordingly: only ordering changes
(the `a_view` view moves to its canonical oid position); struct/class contents
are byte-identical. TypeScript and Swift sort internally and are unaffected.

Requires @supabase/postgrest-typegen with sortGeneratorMetadata
(supabase/pg-toolbelt#302).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B53a2ayu9d16u821FQ5Qqz

* test: regenerate typegen snapshots for semantic metadata ordering

Follow-up to the sortGeneratorMetadata semantic-key change
(supabase/pg-toolbelt#302): the canonical order is now schema+name based, so
the Go/Python typegen snapshots are regenerated to alphabetical order. Pure
reorder — struct/class contents are byte-identical. TypeScript/Swift sort
internally and are unaffected.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B53a2ayu9d16u821FQ5Qqz

* chore: refresh lockfile for semantic-key sort build

* chore: refresh lockfile for semantic-key sort build

* chore: repin @supabase/postgrest-typegen to released ^0.1.0

* fix: honor PG_META_GENERATE_TYPES_DEFAULT_SCHEMA in the typescript generator route

* fix: restore worker-thread type generation on top of postgrest-typegen

The postgrest-typegen refactor dropped the worker path added in #1102: the
route calls generateTypescript() directly, the package formats with prettier
inline and exposes no format hook, so format-pool, format-worker, the piscina
dependency and the 503 load-shedding path were all left dead while CLAUDE.md
still documented the feature.

Rather than wait for a format hook upstream, hand the whole generateTypescript
call to the worker. Measured on a synthetic public schema (12 columns and 2
foreign keys per table), 400 tables: wall clock 1059ms on a worker vs 1065ms
inline, with the longest main-thread block dropping from ~1000ms to 21ms.
Metadata crosses the boundary as a structured clone, which is plain JSON and
costs nothing measurable. This also covers the ~10% of the cost that is string
building rather than prettier, which a format-only hook would have left on the
main thread.

format-pool/format-worker are renamed to typegen-pool/typegen-worker since they
no longer format, keeping the admission control, per-task timeout, idle pool and
503 shedding as they were. The PG_META_FORMAT_* env vars keep their names so
existing deployments do not need reconfiguring.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0192KEBCPggQgUT7JLPc3Cz1

* chore: drop unrelated CLAUDE.md reflow and keep format callbacks off the worker boundary

* chore: bump @supabase/postgrest-typegen to ^0.2.0

0.2.0 formats with oxfmt instead of prettier (typescript snapshots regenerated; the only output change is oxfmt parenthesizing conditional types in generic-default positions), runs its introspection queries concurrently, and accepts a format hook, which stays unused here since the whole generateTypescript call already runs on the worker.

* chore: restore master's format-pool naming to minimize the diff

The typegen-pool/typegen-worker rename made the route's unchanged 503
load-shedding block show up as a diff against master because the error class
inside it changed name. Keep master's file and identifier names (format-pool,
format-worker, FormatQueueFullError, destroyFormatPool, isFormatPoolActive) so
the only diff left in these files is the delegation itself: the worker task
carries generator metadata into @supabase/postgrest-typegen's generateTypescript
instead of a prettier payload, and the exported entry point is
generateTypescriptTypes instead of format(code, options). No behavior change.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0192KEBCPggQgUT7JLPc3Cz1

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Lukas Klingsbo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pg_authid dependency makes using managed postgres impossible

2 participants