postgres: db:create should not fail if the database does exist
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, node.js, postgresql
Research direction
Start with the sequelize db:create entry point and reproduce the issue using the PostgreSQL Docker command and URL shown. Trace the PostgreSQL database-creation path and verify that running the command a second time exits successfully when the database already exists.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- JavaScript
- Stars
- 2.6k
- Forks
- 524
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sequelize/cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·