neondatabase / neonctl

Neon CLI tool. The Neon CLI is a command-line interface that lets you manage Neon Serverless Postgres directly from the terminal.
https://neon.tech/docs/reference/neon-cli
Apache License 2.0
51 stars 10 forks source link

create-app (aka bootstrap) by default assumes that `neondb_owner` user already exists #272

Open mrl5 opened 3 weeks ago

mrl5 commented 3 weeks ago

neonctl bootstrap (aka create-app) by default assumes that neondb_owner user already exists and at the same time doesn't accept owner_name as a parameter

Steps to reproduce

  1. Create some project and database, don't use neondb name.
  2. Make sure that neondb_owner user doesn't exists.
  3. Run neonctl bootstrap

Expected result

Actual result

<REDACTED>
✔ What Neon project would you like to use? › some_existing_project
Branch
┌─────────────────────────┬────────────────┬─────────┬─────────┬──────────────────────┬──────────────────────┐
│ Id                      │ Name           │ Primary │ Default │ Created At           │ Updated At           │
├─────────────────────────┼────────────────┼─────────┼─────────┼──────────────────────┼──────────────────────┤
│ br-misty-bonus-a29xcad8 │ dev/y8pjG4iG3d │ false   │ false   │ 2024-08-23T20:41:21Z │ 2024-08-23T20:41:21Z │
└─────────────────────────┴────────────────┴─────────┴─────────┴──────────────────────┴──────────────────────┘
INFO: Resource is locked. Waiting 3000ms before retrying...
ERROR: database owner not found

which under the hood comes from

curl -i --request POST \
    --url https://console.neon.tech/api/v2/projects/ancient-bush-51935299/branches/br-blue-surf-a2a0d1bc/databases \
    --header "Authorization: Bearer $token" \
    --header 'accept: application/json' \
    --header 'content-type: application/json' \
    --data '
{
  "database": {
    "name": "slo",
    "owner_name": "casey"
  }
}
'
HTTP/2 422

{"code":"","message":"database owner not found"}

Nice to have

additional --owner-name flag where you can define it. I think it could also be created if not exist but that's debatable otherwise this could be reused https://github.com/neondatabase/neonctl/blob/76f9b9fabb2c56c30e8f930a142f2d11532e5419/src/commands/databases.ts#L80-L93