Skip to content

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

Closed
@andyautida14

Description

@andyautida14

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions