Existing migrations don't run when generating migrations

Open
#12,431 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
postgresql, sqlite, typescript
Domain
databases

Research direction

Start with the migrations:generate command and the data-source.ts configuration described in the reproduction steps, using migrationsRun: true and the PGlite driver. Verify the current behavior by generating migrations twice, then confirm that existing migrations run before change detection and the second generated migration no longer repeats their queries.

Written by the indexing model from the issue text.

Description

bug
Issue description

In the documentation mentions that we can configure migrationsRun: true but when generating new migrations it is not honored. Removing this behavior could be useful if the connection is an in-memory database like pglite.

Expected Behavior

When migrationsRun: true is set in data-source.ts, existing migrations run before checking for changes and generating the new migration.

Actual Behavior

When migrationsRun: true is set in data-source.ts, existing migrations don't run before checking for changes and generation. If we use a in-memory db this will generate the new migration with queries existing in previous migrations.

Steps to reproduce
  1. Set "type": "module" in package.json
  2. Set migrationsRun: true in data-source.ts.
  3. Using import {PGliteDriver} from 'typeorm-pglite' set driver to new PGliteDriver().driver in data-source.ts.
  4. Run typeorm-ts-node-esm migrations:generate -d data-source.ts migrations/<name> twice.
My Environment
Dependency Version
Operating System Darwin Kernel Version 25.4.0
Node.js version 24.15.0
Typescript version 5.9.3
TypeORM version 0.3.28
Additional Context

No response

Relevant Database Driver(s)
  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • capacitor
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqljs
  • sqlserver
Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, and I know how to start.

Dominant language
TypeScript
Stars
36.7k
Forks
6.7k
Avg merge
3d 1h
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from typeorm/typeorm

All issues in typeorm/typeorm

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.