Skip to content

Fake flag doesn't propagate to MigrationExecutor on revert #9561

@barakshelef-oasis

Description

@barakshelef-oasis

Issue Description

When running typeorm migration:revert --fake the fake flag isn't passed in the options to runMigrations

Expected Behavior

The migration's down method won't be executed, but the migration record will be removed from the executed migrations table.

Actual Behavior

The down method is executed.

Steps to Reproduce

  1. Create empty migration and add it to your data-source: typeorm migration:create testFakeFlag
  2. In the down method add a console print console.log("It's going down!")
  3. Run migration: typeorm migration:run -d src/data-source.ts
  4. Fake revert migration: typeorm migration:revert -d src/data-source.ts

My Environment

node 18.12
typescript 4.9.3
typeorm 0.3.10

using a mongo data source.
mongodb (node.js package) 4.12
mongodb (server) 6.0.2

Additional Context

This is clear from PR #8976 which introduced this feature. Just missing this line from MigrationRevertCommand.ts

const options = {
...
                 fake: !!args.f,
}

and an appropriate test.

Relevant Database Driver(s)

technically only tested on mongo -- but the issue is quite clearly not db dependent.

DB Type Reproducible
aurora-mysql no
aurora-postgres no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb yes
mysql no
nativescript no
oracle no
postgres no
react-native no
sap no
spanner no
sqlite no
sqlite-abstract no
sqljs no
sqlserver no

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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions