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

Generating a migration script using the programmable API does not use the name provided in the arguments #652

Closed
1 of 3 tasks
andyautida14 opened this issue Oct 14, 2019 · 4 comments · Fixed by #678
Closed
1 of 3 tasks
Labels

Comments

@andyautida14
Copy link

andyautida14 commented Oct 14, 2019

I'm submitting a...

  • Bug report
  • Feature request
  • Question

Current behavior

The migrationName parameter provided on create method of the programmable API is ignored when creating a migration. It instead uses the first command-line argument as the name.

Expected behavior

Use the migrationName parameter passed to the create method as the name of the new migration.

Minimal reproduction of the problem with instructions

index.js:

const program = require('commander')
const dbMigrate = require('db-migrate')

program
  .command('migration <name>')
  .description('create a new migration script')
  .action(async function(name) {
    console.log('name:', name)
    const instance = dbMigrate.getInstance(true)
    await instance.create(name)
  })

program.parse(process.argv)

running the command above will produce the following output:

$ DATABASE_URL=postgres://localhost:5432/sample node . migration this-should-be-the-name-of-migration
name: this-should-be-the-name-of-migration
[INFO] Created migration at /Users/user/db-migrate-bug/migrations/20191014092749-migration.js

The filename produced is the same as the one logged above.

What is the motivation / use case for changing the behavior?

to be able to create migration files with correct file names programmatically

Environment


db-migrate version: 0.11.6
db-migrate-pg version: 1.0.0

Additional information:
- Node version: v12.7.0
- Platform:  Mac




---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/82208238-generating-a-migration-script-using-the-programmable-api-does-not-use-the-name-provided-in-the-arguments?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github).
@stale
Copy link

stale bot commented Nov 17, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 17, 2019
@andyautida14
Copy link
Author

Any updates on this?

@stale stale bot removed the stale label Nov 19, 2019
@stale
Copy link

stale bot commented Dec 19, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 19, 2019
@wzrdtales wzrdtales added the bug label Dec 22, 2019
@stale stale bot removed the stale label Dec 22, 2019
@wzrdtales
Copy link
Member

This is due to the following

internals.argv.title = internals.argv._.shift();

This is shifting out the variable, while this is pushing in

this.internals.argv._.push(migrationName);

needs to be fixed in the api.js

thank you for reporting!

confuser added a commit to confuser/node-db-migrate that referenced this issue Apr 2, 2020
confuser added a commit to confuser/node-db-migrate that referenced this issue Apr 2, 2020
fixes db-migrate#652

Signed-off-by: James Mortemore <jamesmortemore@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants