db-migrate / db-migrate/node-db-migrate

Programmable API createDatabase arguments are overridden

Open
#578 11 comments 0 reactions 0 assignees View on GitHub
bug needs confirmation
Dominant language
JavaScript
Stars
2.3k
Forks
361
PR merge metrics
No merged PRs in 30d

Description

## I'm submitting a...

- [X] Bug report
- [ ] Feature request
- [ ] Question

## Current behavior

Command line parameters override `createDatabase` parameters in [Programable API](https://db-migrate.readthedocs.io/en/latest/API/programable/#createdatabasedbname-callback).

```
$ DATABASE_URL=postgres://localhost/postgres node index.js
[INFO] Created database "expected"
$ DATABASE_URL=postgres://localhost/postgres node index.js unexpected
[INFO] Created database "unexpected"
```

## Expected behavior

I would expect parameters provided to `createDatabase` always override possible command line arguments.

```
$ DATABASE_URL=postgres://localhost/postgres node index.js
[INFO] Created database "expected"
$ DATABASE_URL=postgres://localhost/postgres node index.js unexpected
[INFO] Created database "expected"
```

## Minimal reproduction of the problem with instructions

```
$ cat index.js
var dbmigrate = require('db-migrate');
var dbm = dbmigrate.getInstance(true);
dbm.createDatabase('expected')
.then(function() {
process.exit(0);
});
```

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

Using `createDatabase` through Programable API in an program that has command line args is not possible at the moment.

## Environment

db-migrate version: 0.11.1

db-migrate-pg version: 0.4.0

Additional information:
- Node version: v10.6.0
- Platform: Mac

---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/61265315-programmable-api-createdatabase-arguments-are-overridden?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).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.