Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mikro-orm migration:fresh --drop-db runs migrations against wrong db #5583

Closed
5 tasks done
petergledhillinclusive opened this issue May 17, 2024 · 0 comments
Closed
5 tasks done

Comments

@petergledhillinclusive
Copy link

Describe the bug

When the migration:fresh command is run with drop-db, the database is dropped correctly but then the migrations are run against the 'postgres' db rather that the db specified in the config.

Reproduction

When generate.dropSchema is executed with 'dropDb: true' Mikro connects to the 'postgres' db to run the drop command command but then never switches back to the user provided dbName.

private static async handleFreshCommand(args: ArgumentsCamelCase<Opts>, migrator: IMigrator, orm: MikroORM) {
   console.log(orm.config.get('dbName')); // dbName is correct
   await generator.dropSchema({ dropMigrationsTable: true, dropDb: args.dropDb });
   console.log(orm.config.get('dbName')); // dbName is now 'postgres' - migrations run against 'postgres' db rather than the original db

What driver are you using?

@mikro-orm/postgresql

MikroORM version

6.2.6

Node.js version

20.9.0

Operating system

macOS

Validations

@B4nan B4nan closed this as completed in 725f7e9 May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant