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/CockroachDB: spatial columns without spatialFeatureType or srid generate an endless no-op migration #12811
A geometry or geography column declared without spatialFeatureType or srid produces the same ALTER COLUMN ... TYPE statement on every migration:generate, even though nothing changed and running the generated migration is a no-op.
Expected Behavior
Once the schema is in sync, migration:generate reports "No changes in database schema were found."
Actual Behavior
Every run emits, for each such column:
ALTERTABLE"post" ALTER COLUMN "geom" TYPE geometry
ALTERTABLE"post" ALTER COLUMN "pointWithoutSRID" TYPE geometry(Point)
ALTERTABLE"post" ALTER COLUMN "geog" TYPE geography
This reproduces with the repository's own spatial test entity (test/functional/spatial/postgres/entity/Post.ts): logging the schema builder against it returns those three queries on PostGIS 3.6 and on CockroachDB v24.3.8 alike.
Cause: the column is created as plain geometry, which geometry_columns reports back as feature type GEOMETRY with SRID 0, while the entity metadata keeps both undefined. findChangedColumns compares the raw values, so the column always looks changed. The decorator reference already documents those defaults ("If not specified, it will behave as though Geometry was provided" and "If not specified, it will default to 0"); they are simply not applied in the comparison.
This is distinct from #12800, which is about precision on spatial columns.
Steps to reproduce
@Entity()exportclassPost{
@PrimaryGeneratedColumn()id: number
@Column("geometry",{nullable: true})geom: Geometry
@Column("geometry",{nullable: true,spatialFeatureType: "Point"})pointWithoutSRID: Point
@Column("geography",{nullable: true})geog: Geography}
Synchronize or create the schema.
Run migration:generate (or createSchemaBuilder().log()): three ALTER COLUMN ... TYPE statements.
Apply them and generate again: the same three statements.
Activity