TL;DR: The server is fine, the database just was never created. Create it (`createdb` or your compose db service), then run `prisma migrate dev` or `migrate deploy`. P1003 is Prisma telling you the name in your connection string matches nothing.

```text
Error: P1003: Database `mydb` does not exist on the database server at `YOUR_HOST:5432`.
```

## Steps

1. Confirm the database is really missing:
   ```bash
   psql -h YOUR_HOST -U postgres -lqt | cut -d '|' -f 1 | grep -w mydb
   ```
   Expected: no output. If it prints the name, your connection string points at the wrong server.

2. Create it. Pick the one that matches your setup:
   ```bash
   createdb -h YOUR_HOST -U postgres mydb
   ```
   or start the compose service that owns it:
   ```bash
   docker compose up -d db
   ```
   Expected: the name now appears in the database list.

3. Build the schema inside it:
   ```bash
   npx prisma migrate deploy
   ```
   Expected: `All migrations have been successfully applied.` P1003 is gone.

## When to use
- The exact code is P1003 and you can connect to the server itself
- Fresh setups, new branches, or restored servers where the database was never created

## When not to use
- P1001: you cannot reach the server at all
- P1000: the server rejects your credentials before the database name even matters

## Compatibility
Prisma Client and Migrate 4.x through 6.x. PostgreSQL, MySQL, SQL Server.

### Variant phrasing: P1003 in tests that use a separate test database
Create the test database in your test setup script before migrations run, not after.

### Variant phrasing: P1003 after dropping the database by hand
Recreate it and re-run `migrate deploy`; there is no shortcut around the missing database.

## Why it happens
Prisma connects to the server first, then selects the database named in the connection string. `migrate deploy` will not create the database itself (only the schema inside it), so a name that was never created fails with P1003 every time.

## Edge cases
- Case sensitivity: `MyDB` and `mydb` are different names on most servers; match the connection string exactly.
- Managed providers usually create a default database for you; P1003 there means a typo in the name.
- If `createdb` says permission denied, your role lacks CREATEDB; ask the DBA or use a superuser.