Repository navigation
Description
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.

Activity
imnotjames commentedon Jul 26, 2021
Best guess without digging into it:
The
falseis normalized by the postgres database server to beFALSEwhichFALSE !== falseso it generates a new one.chandrashekhar07 commentedon Jul 26, 2021
@imnotjames , i tried changing default value to FALSE, but still same sql query is regenerated,
denvolok commentedon Jul 29, 2021
imnotjames commentedon Jul 29, 2021
RS-DU34 commentedon Aug 23, 2021
it's not clear on your post, looks like you didn't....
; did you actually run the migration or just the generate command?
the generate command just generates code by looking at the db. If you dont use the
runcommand, the db is unchanged and the next generate will find the db in the same state 😊chandrashekhar07 commentedon Aug 23, 2021
@lflfm i have run the migration command (after generating it),
and even after running the migration command,
Migration:generate command is generating migration files which contains same SQL query as of first migration.
RS-DU34 commentedon Aug 23, 2021
which migration command? did you run
migration:run?correct order is:
typeorm-cli migration:generate -n mynewChangestypeorm-cli migration:runtypeorm-cli migration:generate -n someMoreChangeschandrashekhar07 commentedon Aug 23, 2021
@lflfm yeah i know the correct order and i have followed the same order (you can check on photo attached above, i have merged generate and run command with && )
here,
typeorm-cli migration:generate -n someMoreChangesis generating same sql files as oftypeorm-cli migration:generate -n mynewChangesRS-DU34 commentedon Aug 23, 2021
Sorry, I hadn't read the command completely.
The only thing I notice now then is that the migrate up is trying to set default to a
stringthat says'false'while the migrate down sets the default to abooleanfalse. Maybe that's the issue?Have you tried to set the default as a boolean in your model?
instead of:
@Column({ name: 'is_deleted', type: 'boolean', default: 'false' })try:
@Column({ name: 'is_deleted', type: 'boolean', default: false })chandrashekhar07 commentedon Aug 23, 2021
@lflfm Thank u man, setting
default:falsesolves the issueforrestwilkins commentedon Jul 25, 2023
I'm getting a similar issue to this. I get the following SQL generated, even though no changes have been made to the
GroupMemberRequestentity in ages:I've cleared out my
distfolder and also tried recreating my local dev database with no luck.forrestwilkins commentedon Jul 25, 2023
Has anyone tried the solution found here by chance?
CodySwannGT commentedon Nov 9, 2023
Having the same issue
sjlehn commentedon May 17, 2024
I just did. It didn't help. I still have a pile of bogus migrations that re-create a handful of indexes and foreign keys, as well as some regular fields. There's no difference in what's in
upvs what's indown. When I dig into the debugger, it looks like it thinks the FKs should be cascading when they're not (innode_modules/typeorm/schema-builder/RdbmsSchemaBuilder.js::dropOldForeignKeys), though the generated update shows NO ACTION, which matches the existing table.Some of the fields being re-created are shared by 40 some tables (they're history fields - createdAt, modifiedAt, etc), yet only 3 tables are getting fake migrations generated - and by shared I mean they all exist on the same superclass. It's the exact same code that somehow triggers a migration for 3/49 entities. I can't figure out what makes those particular tables unique.
zedjarvis commentedon Jul 26, 2024
I realized that the
migration:generatewill re-create the same migration only if you have not executedmigrations:run. After running migration then try to re-generate without changes you will get the following messageNo changes in database schema were found - cannot generate a migration. To create a new empty migration use "typeorm migration:create" commandsjlehn commentedon Jul 26, 2024
Our 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.nojcc commentedon Aug 10, 2024
Years later, this is still an issue smh
github-actions commentedon Sep 18, 2025
TypeORM has returned to active development after recently transitioning to new leadership (see related announcement).
As part of the new team's efforts to prioritise work on the project moving forward, it is necessary to clean up the backlog of stale issues.
🧹 This issue is being automatically closed because it has had no activity in the last 6 months.
If you believe this issue is still relevant, feel free to comment below and the maintainers may reopen it. Thank you for your contribution.