Skip to content

TypeORM Migration Generation Error – Migrations Are Regenerated From Scratch #2556

@PooyaRaki

Description

@PooyaRaki

Description

When using the typeorm migration:generate command, it generates a migration that includes all entities as if it’s the initial migration, rather than only generating changes since the last migration. This happens even when no model changes have been made, causing unnecessary and potentially destructive SQL to be generated.

Reproduction steps

  1. Create an initial migration using typeorm migration:generate.
  2. Run the migration and ensure the database is in sync.
  3. Run the migration generation command again without changing any entities:

Expected behavior

The migration generator should detect schema changes and only include operations related to actual differences between the current database schema and the entity definitions.

Additional information

This issue can lead to bloated migration files and potential conflicts in CI/CD pipelines. Could be related to missing metadata or incorrect dataSource configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions