Closed
Description
I'm submitting a...
[x] Bug report
[ ] Feature request
Current behavior
When I run the following command:
db-migrate db:drop -e postgres tesla_data_point_development
I get the following error:
[INFO] Error: Failed to drop database! { error: database "tesla_data_point_development" is being accessed by other users
at Connection.parseE (/Users/landon/Development/tesla/projects/tesla-data-point/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:539:11)
at Connection.parseMessage (/Users/landon/Development/tesla/projects/tesla-data-point/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:366:17)
at Socket.<anonymous> (/Users/landon/Development/tesla/projects/tesla-data-point/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:105:22)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:594:20)
name: 'error',
length: 173,
severity: 'ERROR',
code: '55006',
detail: 'There is 1 other session using the database.',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'dbcommands.c',
line: '876',
routine: 'dropdb' }
However, if I echo the last status (I'm using fish), it seems the process exits with a 0
:
echo $status
0
Expected behavior
The process should exit with a non-zero status.
Minimal reproduction of the problem with instructions
Here's my database.json
file:
{
"postgres": {
"driver": "postgres",
"host": { "ENV": "DATABASE_HOST" },
"user": { "ENV": "DATABASE_USERNAME" },
"password": { "ENV": "DATABASE_PASSWORD" },
"port": { "ENV": "DATABASE_PORT" },
"database": "postgres"
},
"development": {
"driver": "postgres",
"host": { "ENV": "DATABASE_HOST" },
"user": { "ENV": "DATABASE_USERNAME" },
"password": { "ENV": "DATABASE_PASSWORD" },
"port": { "ENV": "DATABASE_PORT" },
"database": "tesla_data_point_development"
},
"test": {
"driver": "postgres",
"host": { "ENV": "DATABASE_HOST" },
"user": { "ENV": "DATABASE_USERNAME" },
"password": { "ENV": "DATABASE_PASSWORD" },
"port": { "ENV": "DATABASE_PORT" },
"database": "tesla_data_point_test"
}
}
I'm happy to provide more detail if needed.
What is the motivation / use case for changing the behavior?
I'm using my package.json
file to create helpers to chain multiple database tasks together. However, if they exit with 0
, then the tasks don't quick when I chain them.
"scripts": {
"db:drop": "db-migrate db:drop -e postgres tesla_data_point_$NODE_ENV",
"db:create": "db-migrate db:create -e postgres tesla_data_point_$NODE_ENV",
"db:migrate": "db-migrate up",
"db:rollback": "db-migrate down",
"db:reset": "yarn db:drop && yarn db:create && yarn db:migrate"
}
Environment
db-migrate version: 0.10.2
db-migrate-pg: 0.2.5
db-migrate-plugin-babel: https://github.com/LandonSchropp/db-migrate-plugin-babel.git
Node: 9.2
Platform: macOS 10.13.2