Databases

Sleep, wake and delete a database

Park a database, reconnect after waking, and remove it when finished

Sleep orders to pause execution while it keeps its memory allocated and its data. Wake it when you need SQL access again. Delete it when you no longer need the database or its data.

Automatic sleep and wake are coming soon

Sleep on idle and wake on connection are not available yet. For now, a database sleeps only when you run nevia pg suspend, and a connection attempt does not wake it. Run nevia pg awake first.

You need the editor or admin role in your workspace and an existing orders database. The examples use the CLI. Over MCP, an agent does the same with sleep_database, wake_database and delete_database. The connection check uses psql. See Create and connect to a database for setup.

Sleep

nevia pg status orders

The state must be ready, with no pending transition or running operation. Finish your queries first, because SQL access is unavailable while the database sleeps. Sleep pauses the machine in memory. It creates no snapshot and releases no RAM. The CLI command pg suspend calls the API's sleep route.

nevia pg suspend orders --wait
nevia pg status orders

The state should be sleeping, with no pending transition. The database keeps its data, host and credentials, but SQL connections can't reach it until you wake it.

Wake

You can wake a sleeping database with no pending transition or running operation:

nevia pg awake orders --wait
nevia pg status orders

The state should be ready. Open a new connection with the same credentials:

psql "$(nevia pg connect orders --uri)" -c 'SELECT 1;'

You should see one row containing 1. Status reads and pg connect don't wake the database, so run pg awake before you reconnect.

Database status doesn't report last connection or query activity, because the control plane can't observe SQL usage yet. Sleep is manual, not triggered by idle activity.

The wait lasts up to 10 minutes. If it times out, track the operation before you issue another lifecycle command.

Protect a database

Block accidental deletion of orders:

nevia pg set orders --protected true

The output shows protected: true. Protection blocks deletion only. You can still sleep, wake or branch the database, and the setting takes effect without a restart.

Delete

Deletion removes the database and its data and interrupts open connections. No operation can be running on the database, and protection must be off. --yes only skips the CLI confirmation. Deleting a parent leaves its branches running with their own data.

If you created orders-staging and no longer need it, delete it first. Clear its protection if you enabled it:

nevia pg rm orders-staging --yes --wait

To delete orders, clear its protection and then delete it:

nevia pg set orders --protected false
nevia pg rm orders --yes --wait
nevia pg ls

The deleted databases should be gone from the list. You can delete a sleeping database without waking it.

See Database lifecycle states for state and persistence rules, and nevia pg for command options.

On this page