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.
You need the CLI installed and signed in, a
selected workspace where you have the admin or editor
role, and an existing orders database. The connection check uses psql.
See Create and connect to a database for setup.
Sleep
nevia pg status ordersThe 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 ordersThe 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 ordersThe 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 trueThe 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 --waitTo delete orders, clear its protection and then delete it:
nevia pg set orders --protected false
nevia pg rm orders --yes --wait
nevia pg lsThe 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.