> ## Documentation Index
> Fetch the complete documentation index at: https://antideploy.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Managed PostgreSQL: Provisioning and Connections

> Antideploy provisions PostgreSQL automatically when your code uses it, and injects the connection string as DATABASE_URL.

If your project uses Postgres, Antideploy creates one for you. You do not
choose a plan, a size, or a region.

## When a database is created

During analysis, Antideploy looks for evidence that your code talks to
Postgres, an ORM or a driver in your dependencies:

* **Node**: Prisma, Drizzle, TypeORM, Sequelize, Knex, `pg`, `postgres`
* **Python**: SQLAlchemy, Django ORM, `psycopg2`, `asyncpg`
* **Other runtimes**: the equivalent Postgres client for your language

When one is found, a database is provisioned before your first deployment
finishes, and its connection string is injected as `DATABASE_URL`.

<Note>
  Provisioning is idempotent per application. Redeploying reuses the existing
  database rather than creating a second one; your data survives every deploy.
</Note>

## Using it

You never hardcode credentials. Read `DATABASE_URL` from the environment:

```js theme={null}
import postgres from "postgres";

const sql = postgres(process.env.DATABASE_URL);
const users = await sql`SELECT * FROM users`;
```

```python theme={null}
import os, psycopg2

conn = psycopg2.connect(os.environ["DATABASE_URL"])
```

Prisma, Drizzle, SQLAlchemy and Django all read `DATABASE_URL` from the
environment by default, so they need no extra configuration.

## Bringing your own database

If your code already uses Supabase, Neon, Firebase or another hosted database,
Antideploy notices and **does not** create a second one. It carries your
existing credentials across instead.

Set the connection string as an environment variable and it is injected at
release, taking precedence over anything Antideploy would have provisioned.

<Card title="Environment variables" icon="key" href="/docs/configuration/environment-variables">
  Supplying your own connection string.
</Card>

## Browsing your data

The dashboard includes a read-only browser for your application's database
(tables, columns, and row counts), so you can confirm a migration landed
without connecting a client.

This works both for databases Antideploy provisioned and for a Postgres URL
you supplied yourself.

## Migrations

If your project has a migration step, Antideploy runs it as part of the
deploy, before the new version starts serving. A failed migration fails the
deploy rather than releasing a version your schema cannot support.

## Lifecycle

The database belongs to the application. Deleting the application deletes the
database and everything in it.

<Warning>
  Deletion is permanent. Antideploy does not expose backups, snapshots or
  point-in-time restore; if you need a copy of your data, take one yourself
  with `pg_dump` before deleting an application.
</Warning>
