• Formerly Platform.sh
  • Contact us
  • Docs
  • Login
Watch a demoFree trial
Blog
Blog
BlogProductCase studiesCompany news
Blog

Add Postgres with one YAML line. Deploy in under a minute.

PostgreSQLIaCconfiguration
11 November 2025
Share

Let’s break down why this matters, and how it can change the way you approach building and running applications.

You want database power without getting bogged down in tooling and config. Most of your week should be building features, not hunting for connection strings or maintaining bespoke infra scripts. Developers tell us they just want to code and solve application problems, with minimal platform friction.

This post walks through how to add PostgreSQL to an Upsun project with a single YAML change, push to your repository, and let Upsun do all the work of deploying a new instance and finish in under a minute. Along the way, you get a production-grade preview environment per branch, safe data cloning with sanitization, and built-in observability that keeps you out of war rooms.

Why Postgres, why now

PostgreSQL has become the most popular database, according to the Stack Overflow Developer Survey, with approximately 49 percent of developers using it in 2024.¹ That popularity comes from a mix of reliability, performance, and an ecosystem that keeps expanding.

There is another reason Postgres fits modern workflows: it pairs naturally with infrastructure defined as code. When your app, services, and policies live in declarative YAML, combined with proper migrations,  your database stops being a snowflake and starts being versioned, repeatable, and easy to automate.

What the flow looks like

Here is the high-level path you will follow:

  1. Add one line to declare a managed Postgres service in .upsun/config.yaml. Upsun’s product pillar is simplicity through a single YAML file. 
  2. Commit and push. Upsun builds and deploys the new Postgres instance automatically, providing your branch with an up-to-date environment. 
  3. Ensure your application uses the environment variables that have been created automatically (DB_*) to connect to the Postgres instance.
  4.  Continue developing your application and its features with a fully managed database. Each new branch will automatically create a preview environment that inherits a cloned copy of the database for testing purposes.
  5. Inspect metrics and logs to validate performance before you merge. Upsun integrates performance monitoring and code profiling for modern and legacy apps.

That is the path we show in the time-lapse demo: from one YAML change to a running Postgres-backed branch preview in under a minute.

One-line Postgres in YAML configuration

If your project already has a services: section, you can declare Postgres with a single inline map:

services:

  db: { type: postgresql:17 }

See the PostgreSQL service reference for a complete documentation of the available options and configuration keys.

If needed, review the YAML structure overview, which explains the top-level keys in config.yaml.

Tip: Your editor can autocomplete Upsun YAML keys using our published schema. See editor autocomplete setup.

Service provisioning that “just works”

Upsun’s managed services are provisioned from YAML and connected to your app with relationships. The Postgres page displays the canonical example, including environment variables such as POSTGRESQL_HOST and POSTGRESQL_PASSWORD, which are automatically injected for you. See PostgreSQL service reference.

To connect from your code, you can read the injected variables or use a convenient DATABASE_URL variable you define in a .environment

The docs include examples and CLI helpers such as upsun sql for direct access. Same reference page as above.

Preview per branch, automatically

Every Git branch gets a live, production-grade environment that includes your code, filesystem data, and cloned services. That means feature branches and pull requests run with the same topology as production, which reduces surprises after merge.

Conceptually, a preview is just another environment in Upsun, managed alongside production and staging. See manage environments.

Why this matters: industry research ties faster, smaller, more frequent deployments to better performance outcomes. The DORA program’s four key metrics remain the standard for measuring delivery performance.² ³ When all your branches can be previewed and tested, right out of the box, you shorten lead time and increase deployment frequency without adding risk.

Instant data cloning, with sanitization

When you branch in Upsun, the platform clones both code and data for that branch by default, so you can test against realistic datasets. You can then sanitize personal data in previews to stay compliant and safe. See sanitize databases overview and a PostgreSQL example for Symfony.

This automated flow reduces the pain and time needed to spin up new environments for testing. And removes any error-prone manual tasks from it. No long manual dumps and imports anymore!

Database scaling from day one

Start simple with one service line, scale when you need to:

  • Scale the resources allocated to Postgres with one CLI command or two clicks!
  • Add multiple databases or users by defining endpoints under the configuration key. Same reference as above.
  • Keep the app stateless. If you run multiple application containers later, the managed database remains a single source of truth. 
  • Observe the different components directly in the platform and profile performance issues with Blackfire.

A quick start you can try today

If you are new to Upsun, the “Configure your project” guide shows where config.yaml lives and how to pre-generate it. 

Prefer hands-on? This Laravel tutorial deploys a REST API on Upsun with Postgres support. See Laravel on Upsun in 10 minutes.

As you iterate, your AI assistants can even understand your stack through our Model Context Protocol servers, which can provide real-time infrastructure context. See connecting a Postgres MCP server.

What you gain in practice

  • Speed. Smaller changes, faster deploys, less waiting.
  • Simplicity. One config.yaml governs apps, services, and policies.
  • Standardization. Same process across teams and repos.
  • Security. Managed services and environment-scoped credentials.
  • Predictable costs. Less bespoke infra to build and maintain.

If your team has felt the grind of too many tools and not enough flow, this is a way to get back to building. Your YAML drives service provisioning, your branches become safe places to test with real data, and your deployments get repeatable, fast, and confident. That is developer productivity, you feel the same day.

Postgres deployment, YAML configuration, and developer productivity

If you remember only one thing, make it this: declare Postgres in YAML, push, and validate in a real preview before you merge. The rest follows naturally. Upsun provides the managed rails so your team can focus on features.

Beyond Postgres

The same pattern applies to Redis, MongoDB, Elasticsearch, Kafka, Solr, and many other systems. Services are declared in YAML, committed to Git, cloned across environments, and managed automatically.

Think of it as infrastructure as version-controlled code. No hidden state, no mystery boxes. Just a predictable workflow that scales with your team.

What to try next

The time-lapse demo demonstrates its speed. But the fundamental shift happens when you try it with your own project (for free).

Spin up an environment, add a service with one line, and see it deploy in under a minute. Push a schema change, clone the database, and test it without fear of breaking production.

That’s the moment when you realize: you’re not just saving time. You’re working differently.

Sources

  1. Stack Overflow Developer Survey 2024, databases and productivity sections
  2. DORA research program overview and 2024 report hub
  3. Google Cloud blog, announcing the 2024 Accelerate State of DevOps Report

Stay updated

Subscribe to our monthly newsletter for the latest updates and news.

Your greatest work
is just on the horizon

Free trial
© 2025 Upsun. All rights reserved.