You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Postgres: geometry column with precision generates an endless phantom migration #12800
A geometry column declared with precision produces the same ALTER COLUMN ... TYPE geometry(...) statements on every migration:generate, even when nothing has changed. Running the generated migration is a no-op, and the next generate emits the identical statements again — an endless phantom diff.
Expected Behavior
After applying a generated migration, a subsequent migration:generate on an unchanged schema should report "No changes in database schema were found."
Actual Behavior
migration:generate repeatedly emits, for each geometry column, an ALTER COLUMN ... TYPE statement even when nothing has changed:
ALTER TABLE "WorkOrder" ALTER COLUMN "geometry" TYPE geometry(Geometry,4326)
Applying the generated migration is a no-op, and the next migration:generate emits the identical statement again — an endless phantom diff that never converges to "No changes in database schema were found."
Steps to reproduce
Define an entity with a geometry column that sets precision (commonly done so TypeORM reads it as ST_AsGeoJSON(col, ) and preserves coordinate digits):
You declare a geometry column with precision: 15. That number only exists in TypeORM's entity metadata — it's used to read the column as ST_AsGeoJSON(col, 15). PostgreSQL never stores it: a geometry column's type is just geometry(Point, 4326) — feature type and SRID, no precision.
So on every sync, TypeORM compares:
entity says precision = 15
database reads back precision = undefined (nothing to store it in)
15 !== undefined is always true → the column is flagged as "changed." Applying a migration can't fix it either, because the geometry type carries no precision to write — so the mismatch is permanent and repeats forever.
Activity
fix: exclude precision/scale from spatial column change detection in …
fix: exclude precision/scale from spatial column change detection in …
mkovac-conductive commentedon Aug 26, 2026
Why the bug happens:
You declare a geometry column with precision: 15. That number only exists in TypeORM's entity metadata — it's used to read the column as ST_AsGeoJSON(col, 15). PostgreSQL never stores it: a geometry column's type is just geometry(Point, 4326) — feature type and SRID, no precision.
So on every sync, TypeORM compares:
15 !== undefined is always true → the column is flagged as "changed." Applying a migration can't fix it either, because the geometry type carries no precision to write — so the mismatch is permanent and repeats forever.
fix: skip precision/scale comparison for column types that don't supp…