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

# Upgrade database

> Upgrade a PostgreSQL database to a newer major version, in place. Other engines are refused.

<Note>
Before upgrading, get the versions this database can take from `upgrade_versions` in [Get database](/api-reference/databases/get-database). When it is empty, `upgrade_note` says why.
</Note>

The upgrade is asynchronous: the call answers at once with the database in status `upgrading`. Poll `GET /api/v1/databases/{database_id}` until `status` is `running`, then read `last_version_upgrade.state`.

- **Backup first**: a backup is taken before anything changes. It is listed with `backup_type` `before_upgrade`.
- **Offline while it upgrades**: about a minute for a small database, longer with many tables.
- **If it cannot complete**: the database returns to its version by itself, unchanged. `last_version_upgrade.state` is `failed` and `message` gives the reason.
- **Afterwards**: extensions are updated, statistics are refreshed and a new backup is taken (`after_upgrade`). A standby and read replicas are rebuilt after the upgrade.

Nothing is ever upgraded automatically. To go back afterwards, restore a backup whose `before_upgrade` is `true` with `POST /api/v1/databases/{database_id}/restore`: over the database (it returns to the older version) or as a new database.

## Errors

- `400`: `version` is missing, or not one of this database's `upgrade_versions`.
- `412`: the database cannot be upgraded right now, with the reason in plain words. For example: it is not running; it is already being upgraded; a column uses a type PostgreSQL cannot carry to a new major version (the message names the columns).




## OpenAPI

````yaml POST /api/v1/databases/{database_id}/upgrade
openapi: 3.0.3
info:
  title: Raff API
  description: >
    REST API for managing cloud infrastructure on Raff.


    ## Authentication

    Most endpoints require authentication via API key. Catalog endpoints under
    `/api/v1/public/` are open and require no authentication.


    ### API Key Authentication

    Include your API key in the `X-API-Key` header:
      ```
      curl -H "X-API-Key: YOUR_API_KEY" https://api.rafftechnologies.com/api/v1/vms
      ```

    ## Catalog

    Use the public catalog endpoints to discover available regions, OS
    templates, and pricing plans before creating resources:

    - `GET /api/v1/public/regions` — list available regions

    - `GET /api/v1/public/templates` — list OS templates (use the `id` as
    `template_id` when creating a VM)

    - `GET /api/v1/public/pricing/vm` — list VM pricing plans (use the `id` as
    `pricing_id` when creating a VM)

    - `GET /api/v1/public/pricing/volume` — volume storage pricing

    - `GET /api/v1/public/pricing/snapshot` — snapshot storage pricing

    - `GET /api/v1/public/pricing/backup` — backup storage pricing

    - `GET /api/v1/public/pricing/ip` — IP address pricing

    - `GET /api/v1/public/pricing/vpn` — VPN gateway and site-to-site tunnel
    pricing

    - `GET /api/v1/public/pricing/database` — managed database pricing (plans,
    high availability, read replicas, extra storage)

    - `GET /api/v1/public/pricing/kubernetes` — managed Kubernetes pricing
    (worker node plans, HA control plane, storage nodes)
  version: 1.0.0
  contact:
    name: Raff Technologies
    url: https://rafftechnologies.com
servers:
  - url: https://api.rafftechnologies.com
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Catalog
    description: >-
      Discover available regions, OS templates, and pricing plans. No
      authentication required.
  - name: Health
    description: Health check endpoints
  - name: Projects
    description: Organize resources into projects for billing and access control
  - name: Virtual Machines
  - name: Kubernetes
    description: >-
      Managed Kubernetes clusters — HA control planes, autoscaling node pools,
      kubeconfig access
  - name: Functions
    description: Deploy and manage serverless functions
  - name: Raff Apps
    description: >-
      Push-to-deploy web services, private services, workers, cron jobs, and
      one-off jobs on the Raff PaaS — with custom domains, environment
      variables, autoscaling, and per-second billing with spend caps
  - name: Managed Databases
    description: >-
      Managed PostgreSQL, MySQL, Valkey, ClickHouse and Kafka with backups, high
      availability, private VPC networking, optional public access over TLS, and
      metrics
  - name: Networking
    description: >-
      Attach and detach VPCs, floating IPs, and security groups to VM network
      interfaces
  - name: Snapshots
    description: Point-in-time copies of VMs and volumes for quick rollback or cloning
  - name: Backups
    description: Scheduled and on-demand VM backups with restore capability
  - name: Backup Schedules
    description: Recurring daily or weekly backup schedules attached to a VM
  - name: SSH Keys
    description: Manage account-level SSH keys for VM provisioning
  - name: Members
    description: Account-level members — invite, list, update role, remove
  - name: Project Members
    description: Members of a specific project — same model as Members but project-scoped
  - name: Roles
    description: Custom roles bundling account or project permissions
  - name: Permissions
    description: List the catalog of permission strings used by roles
  - name: API Keys
    description: Create and manage API keys for programmatic access
  - name: Invitations
    description: Create and cancel email-based invitations to join the account or a project
paths:
  /api/v1/databases/{database_id}/upgrade:
    post:
      tags:
        - Managed Databases
      summary: Upgrade to a newer major version
      description: >
        Upgrade a PostgreSQL database to a newer major version, in place. Other
        engines are refused.


        <Note>

        Before upgrading, get the versions this database can take from
        `upgrade_versions` in [Get
        database](/api-reference/databases/get-database). When it is empty,
        `upgrade_note` says why.

        </Note>


        The upgrade is asynchronous: the call answers at once with the database
        in status `upgrading`. Poll `GET /api/v1/databases/{database_id}` until
        `status` is `running`, then read `last_version_upgrade.state`.


        - **Backup first**: a backup is taken before anything changes. It is
        listed with `backup_type` `before_upgrade`.

        - **Offline while it upgrades**: about a minute for a small database,
        longer with many tables.

        - **If it cannot complete**: the database returns to its version by
        itself, unchanged. `last_version_upgrade.state` is `failed` and
        `message` gives the reason.

        - **Afterwards**: extensions are updated, statistics are refreshed and a
        new backup is taken (`after_upgrade`). A standby and read replicas are
        rebuilt after the upgrade.


        Nothing is ever upgraded automatically. To go back afterwards, restore a
        backup whose `before_upgrade` is `true` with `POST
        /api/v1/databases/{database_id}/restore`: over the database (it returns
        to the older version) or as a new database.


        ## Errors


        - `400`: `version` is missing, or not one of this database's
        `upgrade_versions`.

        - `412`: the database cannot be upgraded right now, with the reason in
        plain words. For example: it is not running; it is already being
        upgraded; a column uses a type PostgreSQL cannot carry to a new major
        version (the message names the columns).
      operationId: upgradeDatabase
      parameters:
        - $ref: '#/components/parameters/DatabaseIDPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpgradeDatabaseRequest'
            example:
              version: '19'
      responses:
        '200':
          description: Upgrade started (status `upgrading`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  database:
                    $ref: '#/components/schemas/Database'
              example:
                success: true
                database:
                  database_id: a1b2c3d4
                  name: orders-db
                  engine: postgres
                  engine_version: '18'
                  status: upgrading
                  status_message: 'Upgrading to PostgreSQL 19: taking a backup first'
                  upgrade_versions:
                    - '19'
                  upgrade_note: ''
                  last_version_upgrade:
                    from_version: '18'
                    to_version: '19'
                    state: backing_up
                    message: ''
                    started_at: '2026-11-25T10:00:00Z'
                    finished_at: ''
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '412':
          description: The database cannot be upgraded right now. `message` says why.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  parameters:
    DatabaseIDPath:
      name: database_id
      in: path
      required: true
      description: >-
        Database ID (UUID) or short id (the `database_id` field, e.g.
        `a1b2c3d4`)
      schema:
        type: string
  schemas:
    UpgradeDatabaseRequest:
      type: object
      required:
        - version
      properties:
        version:
          type: string
          minLength: 1
          description: >-
            The major version to upgrade to, one of the database's
            `upgrade_versions`
          example: '19'
    Database:
      type: object
      description: >
        A managed database instance. The private endpoint
        `{database_id}.db.raffusercloud.com` lives inside the attached VPC;
        public access is optional. TLS is always required.
      properties:
        id:
          type: string
          format: uuid
          description: Unique database identifier
        database_id:
          type: string
          description: Short reference id used in URLs and DNS hostnames, e.g. `a1b2c3d4`
        project_id:
          type: string
          format: uuid
          description: Project this database belongs to
        name:
          type: string
          description: Display name
          example: orders-db
        engine:
          $ref: '#/components/schemas/DatabaseEngine'
        engine_version:
          type: string
          description: Engine major version
          example: '16'
        server_version:
          type: string
          description: >-
            Full version the running server reports, refreshed every few
            minutes. Empty until the first reading after creation.
          example: '16.10'
        status:
          type: string
          enum:
            - pending
            - deploying
            - running
            - warning
            - resizing
            - restoring
            - upgrading
            - moving
            - suspended
            - failed
            - deleting
            - deleted
          description: >
            Lifecycle status.


            - Creation: `pending`, then `deploying`, then `running`. A database
            with public access reports `running` only once its public address
            accepts connections.

            - `warning`: running with a problem (a component down, storage
            full). When the database stopped answering, `down_since` is set.

            - `resizing`: a plan, storage, high availability or replica change
            is being applied (a short restart, not an outage).

            - `restoring`: an in-place restore is in progress.

            - `upgrading`: being upgraded to a newer major version.
            `status_message` says the step. The database is offline for part of
            it.

            - `moving`: Raff is moving the database to other hardware for
            maintenance.

            - `suspended`: a free database paused after 7 days without
            connections. Data is kept; resume with `POST
            /api/v1/databases/{database_id}/resume`.

            - `failed`: provisioning did not complete.

            - `deleting`, `deleted`: being deleted, deleted.
        status_message:
          type: string
          description: >-
            Plain-words detail for `warning`, `resizing`, `upgrading` and
            `failed`
        region:
          type: string
          enum:
            - us-east
          description: Data center region
          example: us-east
        plan_id:
          type: integer
          description: Pricing plan ID (see `GET /api/v1/databases/plans`)
          example: 5
        storage_gb:
          type: integer
          description: >-
            Provisioned storage in GB. Storage above the plan's included storage
            is billed per GB per month (`storage_pricing` in `GET
            /api/v1/databases/plans`, $0.15 today).
          example: 25
        ha_enabled:
          type: boolean
          description: >
            High availability: copies on separate servers that take over
            automatically on failure. PostgreSQL and Valkey run a primary and a
            standby, ClickHouse two replicas, MySQL a 3-node cluster, Kafka 3
            brokers. Adds 70% of the plan price for PostgreSQL, Valkey and
            ClickHouse, 140% for MySQL and Kafka (`ha_pricing` in `GET
            /api/v1/databases/plans`).
        replica_count:
          type: integer
          description: >-
            Number of read replicas (PostgreSQL only; 0 for other engines). Each
            costs the same as the plan.
          example: 0
        vpc_id:
          type: string
          description: VPC the private endpoint is attached to (empty if not yet connected)
        public_access:
          type: boolean
          description: Whether public access is enabled
        connection_host:
          type: string
          description: >-
            Private endpoint hostname, resolvable inside the attached VPC. Use
            it only when `vpc_id` is set; without a VPC the database has no
            private address you can reach.
          example: a1b2c3d4.db.raffusercloud.com
        connection_port:
          type: integer
          description: >-
            Private endpoint port. PostgreSQL: 5432 direct; the pooler
            (PgBouncer, transaction mode) is on 6432 of the same host. MySQL:
            3306. Valkey: 6379. ClickHouse: 8443 (HTTPS), 9440 (native). Kafka:
            9092. Use TLS: databases created from October 13, 2026 refuse
            unencrypted connections.
          example: 5432
        billing_type:
          type: string
          enum:
            - payg
            - subscription
          description: Billing type for this database
          example: payg
        subscription_id:
          type: string
          description: Subscription ID if billing_type is subscription (empty otherwise)
        price_per_hour:
          type: number
          description: Hourly billing rate in USD
          example: 0.010945
        monthly_price:
          type: number
          description: Monthly price in USD
          example: 7.99
        public_port:
          type: integer
          description: >
            The database's own public port on `public_dns_hostname`; `0` when
            public access is off. For PostgreSQL and ClickHouse, `public_port`
            and `public_port + 1` (PostgreSQL: pooled and direct; ClickHouse:
            HTTPS and native). PostgreSQL is also reachable on the standard
            ports 6543 (pooled) and 5432 (direct), routed by the hostname the
            client sends over TLS; use `public_port` for old clients that do not
            send it. The port stays the same when public access is turned off
            and on again.
          example: 20104
        public_dns_hostname:
          type: string
          description: Public endpoint hostname (empty when public access is off)
          example: a1b2c3d4.public.db.raffusercloud.com
        public_allowlist:
          type: array
          items:
            type: string
          description: >-
            Source CIDRs allowed on the public endpoint. Empty = allow all
            sources.
          example:
            - 203.0.113.0/24
        is_free:
          type: boolean
          description: >-
            True for a free-tier database. Free databases pause after 7 days
            without connections.
        suspended_at:
          type: string
          description: >-
            When a free-tier database was paused for idleness, RFC 3339 (empty
            when not paused)
        down_since:
          type: string
          description: >-
            When the database stopped answering, RFC 3339 (empty while it
            answers). Set with status `warning`.
        metrics:
          type: object
          nullable: true
          description: >-
            Latest live numbers, sampled every minute. `null` until the first
            sample.
          properties:
            connections_active:
              type: integer
            connections_max:
              type: integer
            pooled_connections_active:
              type: integer
              description: PostgreSQL pooler
            pooled_connections_max:
              type: integer
              description: PostgreSQL pooler
            storage_used_bytes:
              type: integer
            storage_capacity_bytes:
              type: integer
            ops_per_sec:
              type: number
              description: >-
                Transactions (PostgreSQL), queries (MySQL, ClickHouse) or
                commands (Valkey) per second
            cache_hit_pct:
              type: number
            metrics_updated_at:
              type: string
              description: When the numbers were sampled, RFC 3339
        upgrade_versions:
          type: array
          items:
            type: string
          description: >-
            Major versions this database can be upgraded to, newest first. Empty
            when there is none.
          example:
            - '19'
        upgrade_note:
          type: string
          description: >-
            When `upgrade_versions` is empty and an upgrade exists that this
            database cannot take yet, the reason in plain words. Empty
            otherwise.
        last_version_upgrade:
          allOf:
            - $ref: '#/components/schemas/DatabaseVersionUpgrade'
          nullable: true
          description: >-
            The most recent upgrade to a newer major version, or null if there
            never was one.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
    DatabaseEngine:
      type: string
      enum:
        - postgres
        - mysql
        - valkey
        - clickhouse
        - kafka
      description: >-
        Database engine identifier. Defaults to `postgres` on create; the live
        catalog (including availability and versions) is `GET
        /api/v1/databases/engines`.
      example: postgres
    DatabaseVersionUpgrade:
      type: object
      description: An upgrade of a database to a newer major version.
      properties:
        from_version:
          type: string
          description: Major version before the upgrade
          example: '18'
        to_version:
          type: string
          description: Major version the upgrade goes to
          example: '19'
        state:
          type: string
          enum:
            - backing_up
            - upgrading
            - finishing
            - analyzing
            - done
            - reverting
            - failed
            - undone
          description: >
            Where the upgrade stands.


            - `backing_up`: the backup before the upgrade is running. Nothing
            has changed yet.

            - `upgrading`: the database is offline and being upgraded.

            - `finishing`: up on the new version; extensions are being updated.

            - `analyzing`: running again; statistics are being refreshed.

            - `done`: the upgrade is complete.

            - `reverting`: the upgrade could not complete and the database is
            returning to its version.

            - `failed`: back on its version, unchanged. See `message`.

            - `undone`: it had succeeded and was later returned to the older
            version from a backup.
        message:
          type: string
          description: The reason when `state` is `failed`; empty otherwise
        started_at:
          type: string
          description: When the upgrade started, RFC 3339
        finished_at:
          type: string
          description: When the upgrade finished, RFC 3339 (empty while it runs)
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Authentication required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication. Each key is bound to a specific account.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.