In this section, you’ll learn how to create, modify, and verify changes in a Neon feature database to experience the benefits of isolated development and testing.
Follow these steps to create a feature database in the Neon Console:
feature-test-db
).Result: You’ve created a new feature database with a full copy of the main branch’s data.
Go back to the server and open the terminal.
Export the connection string as an environment variable to simplify future connections:
export FEATURE_DATABASE_CONN="<your-connection-string>" >> ~/.bashrc
Replace <your-connection-string>
with the connection string copied from the Neon Console.
Then to add to apply your updates run:
source ~/.bashrc
Confirm that the environment variable is set:
echo $FEATURE_DATABASE_CONN
You should see your connection string displayed.
Use the connection string to connect to the feature database:
psql $FEATURE_DATABASE_CONN
Verify that the feature database’s data matches the main database:
SELECT * FROM employees.salary LIMIT 15;
Exit the database:
\q
Make schema changes in the feature database without affecting the main database.
Example:
ALTER TABLE employees.salary ADD COLUMN bonus NUMERIC(10, 2) DEFAULT 0;
Verify the change:
SELECT * FROM employees.salary LIMIT 15;
Confirm the bonus column is added.
The connection string for the main database is already saved as an environment variable (DEV_DATABASE_URL
). Use this variable to connect back to the main database:
Connect to the main database using the environment variable:
psql $DEV_DATABASE_URL
Check the schema:
SELECT column_name
FROM information_schema.columns
WHERE table_name = 'salary';
Confirm Main Neon Database is unaffected:
SELECT * FROM employees.salary LIMIT 15;
Result: The
bonus
column will not appear in the main database.
Exit the database:
\q
Once testing is complete, delete the feature database:
feature-test-db
).Alternatively, you can delete the feature database programmatically using the Neon API:
curl -X DELETE https://console.neon.tech/api/v2/projects/<project-id>/branches/<branch-id> \
-H "Authorization: Bearer <api-key>"
With Neon’s branching feature, you’ve:
👉 Use these steps to streamline your dev/test workflows while maintaining safety and efficiency!