typeorm / typeorm

ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
http://typeorm.io
MIT License
34.06k stars 6.27k forks source link

Postgres geometry column is always being altered to type geometry in every migration despite already being type geometry #10870

Open jcapogna opened 5 months ago

jcapogna commented 5 months ago

Issue description

Postgres geometry column is always being altered to type geometry in every migration despite already being type geometry

Expected Behavior

A geometry column that is not modified should not be included in migrations

Actual Behavior

When performing a migration unrelated to a column that is of type geometry, every geometry column I have in my database is included in the migration.

For example:

await queryRunner.query(`ALTER TABLE "locations" ALTER COLUMN "coordinate" TYPE geometry`);

Steps to reproduce

  1. Create an entity with a column of type geometry.

For example:

import {Point} from "geojson";

@Column("geometry")
coordinate!: Point
  1. Create your database with the initial migrations

  2. Alter another table in some way.

  3. See that the migrations include modifying the entity with the geometry type.

For example:

await queryRunner.query(`ALTER TABLE "some_other_table" ALTER COLUMN "coordinate" TYPE geometry`);

My Environment

Dependency Version
Operating System OSX
Node.js version 20.11.0
Typescript version 5.4.2
TypeORM version 0.3.20

Additional Context

No response

Relevant Database Driver(s)

Are you willing to resolve this issue by submitting a Pull Request?

No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

jcapogna commented 4 months ago

As further testing. I applied the migrations generated, then generated migrations again and it generated the same migrations again. It's clear these migrations are a noop, despite being generated.