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

Configuration defaultEnv default value is not readed

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

Description

## I'm submitting a...

- [x] Bug report

## Current behavior

Default value for property `defaultEnv` is not read

## Expected behavior

If the env variable is not declared use the `default` value

## Minimal reproduction of the problem with instructions

With this configuration

```json
{
"defaultEnv": {
"default": "development",
"ENV": "SSO_DB_ENVIRONMENT"
},
"sql-file": true,
"multipleStatements": true,
"development": {
"driver": "mysql",
"user": "root",
"password": "password",
"host": "localhost",
"port": "3306",
"sql-file": true,
"multipleStatements": true
},
"production": {
"driver": "mysql",
"user": {
"ENV": "SSO_DB_USERNAME"
},
"password": {
"ENV": "SSO_DB_PASSWORD"
},
"host": {
"ENV": "SSO_DB_HOST"
},
"port": {
"ENV": "SSO_DB_PORT"
},
"sql-file": true,
"multipleStatements": true
}
}

```

I run:

`db-migrate --config ./database-creation.json db:create sso`

Return a exit code 1 with this error:

```ssh
[ERROR] Error: Environment(s) '' not found.
at Config.exports.setCurrent (D:\projects\dg\sso-service\node_modules\db-migrate\lib\config.js:23:11)
at Object.exports.loadObject (D:\projects\dg\sso-service\node_modules\db-migrate\lib\config.js:183:11)
at Object.exports.loadFile (D:\projects\dg\sso-service\node_modules\db-migrate\lib\config.js:94:18)
at loadConfig (D:\projects\dg\sso-service\node_modules\db-migrate\lib\commands\helper\load-config.js:12:18)
at new dbmigrate (D:\projects\dg\sso-service\node_modules\db-migrate\api.js:77:43)
at Object.module.exports.getInstance (D:\projects\dg\sso-service\node_modules\db-migrate\index.js:85:10)
at D:\projects\dg\sso-service\node_modules\db-migrate\bin\db-migrate:32:25
at D:\projects\dg\sso-service\node_modules\resolve\lib\async.js:142:25
at maybeRealpath (D:\projects\dg\sso-service\node_modules\resolve\lib\async.js:50:9)
at D:\projects\dg\sso-service\node_modules\resolve\lib\async.js:138:24
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

```

## Environment



db-migrate version: 0.11.13
mysql: 2.2.0
Additional information:
- Node version: v16.13.1
- Platform: Windows 10

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.