Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Postgres guide walks a pg project through draft, migrate, generate and runtime use, verified end to end against the docker-compose Postgres in packages/pg/test. It lists the gaps found while verifying: the simplified schema reader in packages/pg/src/impl/schema.ts drops serial/identity, enums, domains, functions, triggers, matviews, extensions, non-public schemas and generated columns, and pg typegen differs from SQLite for limit 1, returning, and nullable params. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docs called Postgres a runtime adapter with toolchain docs 'still in progress'. Postgres has a working dialect (draft, migrate, check, generate, format, UI), so: README documents the dialect config key and points limitations at the guide's known gaps; adapters, errors, formatter, lint plugin and schema-diff pages say what's true for pg today (including that pg errors are always kind 'unknown'); the intro blog post links the guide; @sqlfu/pg gets a README so its npm page isn't empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main added a celld guide alongside the Postgres guides here. Both sides appended to the Guides description in sync-docs.mjs; kept both and regenerated llms.txt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Task file for replacing @sqlfu/pg's hand-rolled pg_catalog renderer with the vendored migra, so materializeSchemaSql/extractSchemaFromClient round-trip real Postgres schemas. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
materializeSchemaSql/extractSchemaFromClient output, diffed against the original schema in both directions, should be empty. Fails today for serial, identity, enums, domains, generated columns, functions, triggers, matviews, extensions and non-public schemas. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
materializeSchemaSql and extractSchemaFromClient now render a schema as migra's diff from an empty inspector to the inspected database, replacing the hand-rolled pg_catalog renderer. diffSchema runs the same migra, so a rendered schema diffs as identical to its source: serial, identity, enums, domains, generated columns, functions, triggers, matviews, extensions and non-public schemas all round-trip now. Vendored migra/schemainspect fixes found on the way, each marked sqlfu:: - new domains are created before tables, and create domain ends with ; - the enums query no longer returns domains over enums - create table keeps column collations Docs: Postgres known gaps shrink to the remaining migra ordering bug (functions/composite types created after the tables using them), ICU collations, and comments/grants. tasks/pg.md step three item ticked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # README.md # packages/sqlfu/README.md # packages/sqlfu/docs/guides/pgkit.md # packages/sqlfu/docs/guides/postgres.md # tasks/pg.md
commit: |
Collaborator
Author
|
🤖 Folded into #159 (shared "Make Postgres work on real schemas" PR, branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #161, which GitHub closed when its base (
pg-docs, #156) merged.draft,checkandgeneratere-read Postgres schemas as SQL text, then diff that text. The text came from a hand-rolledpg_catalogrenderer that only knewpublictables, columns, constraints, indexes and views. Everything else was lost, so most real schemas broke:serialmadegeneratefail, identity columns came back in every draft, enums and domains didn't replay.Now the text is migra's diff from an empty database to yours (what pgkit's migrator does for
definitions.sql).diffSchemaalready uses the same migra, so whatever it can diff, the renderer can render.Round-trips after this PR (
materializeSchemaSql, thendiffSchemaboth ways, empty):serial/bigserial, identity, enums, domains (incl. over enums), stored generated columns, functions, triggers, materialized views, extensions, non-publicschemas, column collations. Plus 30-odd shapes probed by hand (partitions, RLS, inheritance, exclusion constraints,setoffunctions, ...).Rendered schema, before / after
Before (no enum, no sequence, constraint names dropped):
After (same style as Postgres drafts):
This is what the UI's live-schema pane shows now.
Still broken
migra creates every function and composite type after the tables. So a table whose default, check or generated column calls a user function, or that has a composite-type column, fails, in drafts too. Two
test.failscases pin it. It's a migra draft-ordering change that reshuffles fixture output, so it's left for its own PR (listed intasks/pg.md).Also listed in the guide: custom ICU collations lose
locale/deterministic; comments and grants are never drafted.packages/pg/src/impl/schema.ts:renderCanonicalSchema+ itspg_catalogqueries replaced byrenderSchema(migra fromPostgreSQL.empty()to the inspected db)omitTablesin the same fileexcludedTables(e.g.sqlfu_migrations) drops the table plus its indexes, constraints, triggers, policies and owned sequences from the inspector.publicschema andplpgsqlextensioncreate schema if not exists "public"was noise in the UI pane.vendor/migra/migra.ts,changes.ts: create new domains before tablestype "email" does not exist). Modified domains keep the old drop-then-create spot.vendor/schemainspect/pg/obj.ts:create domainends with;vendor/schemainspect/queries.ts: enums query usestyptype = 'e'typcategory = 'E'also matched domains over enums, so they were created twice.vendor/schemainspect/inspected.ts: collation inColumnInfo.creation_clausecreate tabledroppedcollate "C"; onlyadd columnkept it.packages/pg/test/schema-round-trip.test.tsextractSchemaFromClienton a live db andexcludedTables.docs/guides/postgres.md,guides/pgkit.md,packages/sqlfu/README.mduuidortextids for now" and the pgkit "schema coverage" caveat.tasks/pg.md,tasks/complete/2026-10-29-pg-lossless-schema.mdTested:
@sqlfu/pgtypecheck + full suite (postgres:16 frompackages/pg/test/docker-compose.yml), andpackages/ui/test/pg-studio.spec.ts(3/3).Session: "Fix Postgres schema renderer for real schemas" (Claude Code desktop
local_ed3d974f-6104-480c-859b-ff1425e11662, CLI7f20d0b1-4a1e-4bfc-9594-63bff2958ec5)🤖 Generated with Claude Code
Package size — packed 280.7 kB (-2 B, 0)
Package size
dist/vendor/*.jsbundlesvendor/sha256.jsvendor/sql-formatter/*.jsvendor/sqlfu-sqlite-parser/*.jsvendor/standard-schema/*.jsvendor/typesql/*.jsMeasured with
npm pack --dry-run --jsononsqlfu(0.0.0-dev on main vs 0.0.0-dev on this PR).