typeorm: Typeorm generating migrations even though there is not any change in models
Issue Description
i created a passenger.entity.ts file added few fields over it. Then i generated a migration named first and i run migration run command successfully and then i can feel changes to my PostgreSQL database,
after few minutes, again i generated a migration named second,
here i am surprised to see that the second migration even generate the same SQL query as of first migrations.
Expected Behavior
i believe when i run command to generated second migration, it should show "typeORM No changes in database schema were found - cannot generate a migration. To create a new empty migration use “typeorm migration:create” command "
Actual Behavior
when i run first migration, following code is generated:
import {MigrationInterface, QueryRunner} from "typeorm";
export class first1627232991461 implements MigrationInterface {
name = 'first1627232991461'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "passengers" ALTER COLUMN "is_deleted" SET DEFAULT 'false'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "passengers" ALTER COLUMN "is_deleted" SET DEFAULT false`);
}
}
when i run second migration command, following code is genetated:
import {MigrationInterface, QueryRunner} from "typeorm";
export class second1627234626276 implements MigrationInterface {
name = 'second1627234626276'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "passengers" ALTER COLUMN "is_deleted" SET DEFAULT 'false'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "passengers" ALTER COLUMN "is_deleted" SET DEFAULT false`);
}
}
Surprisingly in both case there is same sql query
Steps to Reproduce
name of my column is inside .entity.ts file is:
@Column({ name: 'is_deleted', type: 'boolean', default: 'false' })
public isDeleted: boolean;
My Environment
| Dependency | Version |
|---|---|
| Operating System | Ubuntu 20.04 |
| Node.js version | 14.16.1 |
| Typescript version | 4…2.4 |
| TypeORM version | 0.2.32 |
Additional Context
i believe following image clearly show this issue

Relevant Database Driver(s)
| DB Type | Reproducible |
|---|---|
postgres |
yes |
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✅ Yes, I have the time, but I don’t know how to start. I would need guidance.
- ✖️ No, I don’t have the time, but I can support (using donations) development.
- ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 2
- Comments: 17 (2 by maintainers)
@lflfm Thank u man, setting
default:falsesolves the issueOur team found the source of the additional migrations in our project; it was a configuration issue. We were defining ManyToMany relationships multiple times for a single relation, once with
@ManyToManyfrom entity to entity, and again with@JoinTableon both sides that pointed to the junction table. This resulted in TypeORM creating two entities for every relation, and any discrepancy between the two caused the additional migrations. If you’re defining manual junction tables via@JoinTable(b/c you need additional data there), you can’t use@ManyToMany, and vice-versa.