cli
cli copied to clipboard
postgres: db:create should not fail if the database does exist
What you are doing?
To reproduce:
Launch a postgres database:
docker run -e POSTGRES_PASSWORD=password -p 5432:5432 postgres:11
Create a directory with this package.json
:
{
"name": "sequelize-test",
"scripts": {
"db:create": "sequelize db:create --url 'postgres://postgres:password@localhost:5432/database'"
},
"dependencies": {
"pg": "8.11.3",
"sequelize": "6.32.1",
"sequelize-cli": "6.6.1"
}
}
Then run:
$ npm i
$ npm run db:create
> db:create
> sequelize db:create --url 'postgres://postgres:password@localhost:5432/database'
Sequelize CLI [Node: 18.16.1, CLI: 6.6.1, ORM: 6.32.1]
Parsed url postgres://postgres:*****@localhost:5432/database
Database database created.
$ npm run db:create
> db:create
> sequelize db:create --url 'postgres://postgres:password@localhost:5432/database'
Sequelize CLI [Node: 18.16.1, CLI: 6.6.1, ORM: 6.32.1]
Parsed url postgres://postgres:*****@localhost:5432/database
ERROR: database "database" already exists
What do you expect to happen?
The second db:create
should not fail with an error
What is actually happening?
The second db:create
is failing with an error : database "database" already exists
A previous issue was intended to address it but was closed: https://github.com/sequelize/cli/issues/629
Dialect: postgres Database version: 11 Sequelize CLI version: 6.6.1 Sequelize version: 6.32.1