Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgres: db:create should not fail if the database does exist #1368

Open
ledenis opened this issue Aug 23, 2023 · 0 comments
Open

postgres: db:create should not fail if the database does exist #1368

ledenis opened this issue Aug 23, 2023 · 0 comments

Comments

@ledenis
Copy link

ledenis commented Aug 23, 2023

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: #629

Dialect: postgres
Database version: 11
Sequelize CLI version: 6.6.1
Sequelize version: 6.32.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant