Applying Hyperswitch database schema migrations during upgrades

A self-hosting team upgrading Hyperswitch across several releases needs every up.sql file applied in order, with a tested backup and a rollout sequence that matches the schema. This page explains how to plan that work and what drives its effort.

On this page

Applying Hyperswitch database schema migrations during upgrades starts with the version gap

Schema changes in Hyperswitch ship as up.sql files in sub-directories of the repository's migrations directory, and the upgrade runs that SQL against your PostgreSQL database. The number of releases you skip therefore defines the work. Before you touch anything, list every version between the release you run today and the target, then collect the up.sql files for each one in order. A team that jumps from an older release straight to a current one still has to account for every intermediate migration directory, because the database must end in the state the newest application expects. Confirm the exact directory layout for your target tag in the Hyperswitch updates guide and in the repository itself, since the layout is the source of truth for what runs.

Schema changes are harder to undo than image swaps. Redeploying an older router or Control Center image takes minutes, but a column added, renamed or dropped by an up.sql file stays in the database until someone runs deliberate reverse steps, and the Hyperswitch facts supplied here do not describe a down path. That asymmetry shapes the whole plan. The database change is effectively one-way for your purposes, so the backup you take immediately before it, and the ordering of the application rollout around it, decide how recoverable the upgrade is. Ask your Hyperswitch contact or check the release notes for each skipped version whether any migration is marked as non-reversible, and record that answer before the change window.

Treat the version gap as a written inventory that a reviewer can check: target tag, current tag, the ordered list of migration directories, and the owner of each step. For a multi-release move, this list also tells you whether a required service such as Superposition must be running before the database changes, which some releases in the sequence may require. Keep the inventory with the change ticket so the same list drives the backup, the dry run on a restored copy and the production run. Agreeing the list early is the cheapest control in the whole upgrade.

Which release changes affect the database and what each one requires

This table compares the supplied Hyperswitch release changes by their effect on PostgreSQL and the action each one needs before you upgrade. Use it to decide which release notes and migration directories to read first. The main takeaway is that the supplied facts confirm a mechanism and one dependency change, but not the schema contents of each monthly release, so you must read those notes yourself.

ChangeImpact on the databaseAction needed
v1.124.0 Superposition dependencySuperposition became a required configuration dependency, so the upgrade depends on a running service before the new app version starts.Confirm the Superposition service is running before upgrading to v1.124.0, then read the v1.124.0 release notes for any migration steps.
v1.126.0 (August 24, 2026)Schema contents are not stated in the supplied facts. The release includes a compatibility matrix for Control Center and web client versions.Read the v1.126.0 release notes and the up.sql files under the migrations directory for every version you skip.
v1.127.0 (September 28, 2026)Schema contents are not stated in the supplied facts. The release includes a compatibility matrix for Control Center and web client versions.Read the v1.127.0 release notes and list any new up.sql files since your current version.
v1.128.0 (October 16, 2026)Schema contents are not stated in the supplied facts. The release includes a compatibility matrix for Control Center and web client versions.Read the v1.128.0 release notes and confirm the matching Control Center and web client versions.
General up.sql mechanismSQL for schema changes ships in up.sql files in sub-directories of the migrations directory and runs against the database during an upgrade.Apply every up.sql file between your current version and the target version in order, after a verified backup.

How to find the up.sql files for every version you skip

Start by listing the sub-directories of the migrations directory in the Hyperswitch repository, checked out at your current tag and again at your target tag. The Hyperswitch updates guide says schema changes ship as up.sql files inside those sub-directories, and each directory name carries a date-based prefix that gives its position in the sequence. Diff the two listings to get every migration that landed between your current version and the target, including the ones introduced in releases you never ran. Do not assume the list maps neatly onto release numbers. A single release may add several migrations, and a migration may be added in one release and altered in a later one. Confirm the exact file list against the tags you actually deploy, and record the commit hash you used so the list can be reproduced during an audit or a rollback review.

Read the migrations in the order the directory names sort, not in the order you happen to find them. Then open the release notes for each version you skip on the Hyperswitch releases page. Look for dependencies that a SQL file cannot express. The v1.124.0 release notes are the clearest example: they state that Superposition became a required configuration dependency and that a Superposition service must be running before you upgrade to that version. A migration that moves configuration data may therefore only make sense once that service exists. Note every such prerequisite in your upgrade runbook as a separate check, with an owner, so it is not discovered halfway through the rollout. Where release notes are silent, treat that as unknown and confirm the ordering with the Hyperswitch maintainers or in a staging environment rather than inferring it.

Keep this inventory as an artifact in your change record: the tags compared, the ordered file list, the prerequisites found in each release note and the source of each one. Teams that skip several monthly releases often find the list is longer than expected, so decide early whether you will apply the intermediate migrations one by one or move to a later release that consolidates them. Ask the vendor or your partner to state which approach the target release expects. The inventory is also the input to the backup and rollout ordering decisions, because it shows which steps change data in ways that are hard to reverse.

What to prepare before touching the production database

Schema migrations are the step you cannot take back by redeploying images, so the preparation matters more than the command itself. The cards below cover the backup, the inventory of your own changes, the staging rehearsal, the rollback set and the access review that together decide whether a failed migration is a short incident or a data problem.

Verified backup and restore test

A backup only counts once a restore has been tested. Take a fresh backup of the PostgreSQL cluster that Hyperswitch uses, restore it into a separate instance, and confirm the router starts against the restored database. Ask your DBA whether continuous archiving and point-in-time recovery are the reference method for your cluster, and confirm the recovery window covers the moment before the migration runs.

PostgreSQL PITR docs

Inventory of custom schema objects

List every table, index, view, function, trigger and query your team added on top of the Hyperswitch schema, including reporting jobs and BI tools that read directly from the database. Upgrade migrations can alter or drop objects they did not create, so each custom object needs an owner and a check that it still works after the migration runs.

Staging copy of production data

Restore a recent production backup into a staging environment that matches production's PostgreSQL major version and extensions. Run the full set of up.sql files for the versions you skip there first, time the run, and record any errors. Staging data should be masked or access-controlled because it contains payment-related records.

Pinned images and chart set for rollback

Record the exact router, consumer, producer, drainer and Control Center image tags, plus the Helm chart version and values file, that run in production before the upgrade. Keep them in version control so you can redeploy the previous application set even though the database will already carry the new schema.

Access and credential review

Confirm which accounts can run migrations, who holds the database owner credentials, and that the migration job uses a dedicated role with only the privileges it needs. Rotate any shared passwords, check that connection pooling and replica settings point where you expect, and make sure the on-call team can reach the DBA during the window.

PostgreSQL auth methods

The upgrade sequence: migrations, application rollout and checks

This sequence moves a self-hosted Hyperswitch stack from its current release to a target release by proving the schema changes on a copy first, so production changes happen once, with a rollback point in place and a verified state at each stage.

  1. Confirm PostgreSQL and Superposition prerequisites

    Before anything else, confirm that your PostgreSQL major version is still within its support window using the PostgreSQL versioning policy. Check the target Hyperswitch release notes for new required services, such as Superposition for v1.124.0, and confirm that they are running in every environment. Record the current and target versions and the list of up.sql files between them. Done when the team signs off on the version pair and the prerequisites are confirmed in writing for staging and production.

  2. Take a verified backup and rollback point

    The database owner takes a full backup of the production PostgreSQL cluster and records the Hyperswitch image tags and Helm values in use. Confirm that the backup is restorable by restoring it to a separate instance and checking that the router and scheduler tables are present with expected row counts. If point-in-time recovery is in place, record the timestamp just before the change. Done when a restore test has succeeded and the rollback point is labeled with the release and time.

  3. Refresh staging from production

    Restore the latest production backup into a staging PostgreSQL instance that matches production's major version and configuration as closely as possible. Keep staging's Redis and service endpoints separate so that test traffic cannot reach live processors or write webhooks. Done when the staging database is a current copy and the team has confirmed that no production credentials or connectors are reachable from staging.

  4. Apply up.sql files in order on staging

    Locate the up.sql files in the migrations sub-directories for every release between your current version and the target, and apply them in the order the repository and updates guide describe. Capture the output of each run and any errors, and note the time each file took to run on the staging copy. Do not edit the SQL files by hand. Done when every file has applied without error and the migration log is saved with the change ticket.

  5. Run target services against the migrated copy

    Deploy the target router, scheduler producer and consumer, and matching Control Center and SDK versions against the migrated staging database. Run the health checks, then exercise the paths that touch the changed tables: payment creation, capture, refund, webhook delivery, merchant and API key administration, and reporting. Compare results with the same tests run on the pre-upgrade release. Done when those tests pass and the team has reviewed any differences in behavior or logs.

  6. Promote to production with a rollback decision point

    Schedule the production change, confirm the backup and rollback point from step two are still current, and place the database in a state where no other schema change runs in parallel. Apply the same up.sql files in the same order, then roll out the target application services. Verify health checks, error rates and a sample of live transactions before declaring the change complete. Done when production health checks and transaction samples match the staging results.

  7. Decide when rollback stops being a redeploy

    Until the migrations run, rolling back means redeploying the previous images against the same database, which usually works because the old code still reads the old schema. Once any up.sql has applied to production, that path may no longer be valid, because older router code can fail against changed tables. From that point, the practical way back is restoring the backup or point-in-time recovery, which loses writes made after the rollback point. Confirm this rule with the Hyperswitch release notes and your DBA before the change window opens.

How migrations, the Router and Scheduler and PostgreSQL fit together during an upgrade

The upgrade starts with a verified backup of the PostgreSQL primary, then runs the up.sql files for every skipped version against the primary before any new Router or Scheduler pods start. The Producer and Consumer are rolled out only after the schema check passes, and the replica is confirmed to follow the change. At each decision point the team either continues to the next phase or restores from the backup, so the check before rollout is the one that matters most.

Phase order and the checkpoints where the team continues or restores.

How the PostgreSQL version and replicas change the migration plan

The PostgreSQL version under your Hyperswitch database decides how much room the migration plan has. Supported versions today are 18, 17, 16, 15 and 14, with community support for 14 ending November 12, 2026, 15 on November 11, 2027, and 16 on November 9, 2028. Before you apply any up.sql files, confirm which major version you run and whether it stays inside its support window through the target release. A schema migration that you cannot run on a supported major version forces a database upgrade into the same change window, which is a larger risk than the schema change itself.

Keep two kinds of PostgreSQL change apart in your plan. Minor releases do not change the internal storage format, so they only need executables replaced and the server restarted. Major upgrades need pg_dumpall and restore, pg_upgrade, or logical replication, and they are a separate project with their own backup and rollback steps. Logical replication can work between major versions with only several seconds of downtime, according to the PostgreSQL upgrading documentation, but it adds a replication setup that you must build, monitor and tear down. Decide which path you take before you schedule the Hyperswitch migration, not during it.

A primary and replica pair changes the order of operations. Schema changes run against the primary, and a hot standby that serves read-only queries will receive them through replication, so confirm that replication is healthy and lagging by an acceptable amount before the application rollout starts. Synchronous replication makes each commit wait for standbys, which adds latency to migrations that rewrite large tables. PostgreSQL does not detect a failed primary or promote a standby by itself, so automatic failover depends on external tooling that your team must choose, deploy and test. Until that decision is made, plan for a manual promotion and document who performs it.

Questions teams ask before upgrading Hyperswitch schema

How much does an outside team charge to run Hyperswitch schema migrations?

Cost depends on the written scope, not on a standard rate. DeployOpen works from a fixed scope agreed in writing before work starts, and a quote follows from that scope. The main drivers are the number of versions you skip, how many environments must be upgraded (staging, pre-production, production), whether your PostgreSQL primary and replicas need changes, how much backup and restore testing you require, and whether the Superposition or configuration changes in the same window add work. Ask any provider for a quote that lists each environment, each migration step, the rehearsal runs, the cutover window support and the post-upgrade checks as separate line items. Clarify which costs are one-time for the upgrade and which recur if you move to a retainer for ongoing upgrades and support.

How long does a Hyperswitch database migration take?

Duration is set by how far behind you are, how large your database is, and how many environments must be proven before production. The number of up.sql files in the migrations directory between your current and target versions is the first input, because each one must be reviewed and run in order. Data volume matters for any migration that rewrites or backfills large tables, and replica lag and maintenance windows set how quickly you can cut over. Expect the rehearsal runs on a production-sized copy to take the most time. Ask for the duration to be broken into review, rehearsal, production window and verification, and confirm the expected timing against the release notes and your own data size.

What do we need to provide before an outside team starts?

The outside team needs access and information that only your organization holds. Provide the current Hyperswitch version and the target version, the Helm values or deployment manifests in use, read-only access to the PostgreSQL primary and replicas with the schema version table, a copy or snapshot of production-like data for rehearsal, and a recent backup or the ability to take one. You should also supply your change calendar, maintenance windows, on-call contacts, approval paths, and any compliance requirements for change records. Confirm where backups are stored, who can restore them, and how long a restore takes in your environment, because these determine what the plan can promise.

Can our internal team run Hyperswitch migrations without a partner?

Yes, a capable internal team can run the migrations if it has PostgreSQL administration skills, Kubernetes or deployment ownership, and time to rehearse. The work is not only running SQL. It includes reading each up.sql file for locking behavior, large table rewrites and dependencies on the new application version, rehearsing on a restored copy, sequencing the schema change against the router rollout, and verifying the result. Teams usually find the hardest part is the first upgrade, when no internal runbook exists. Consider a partner for the first rehearsal and runbook, then run later upgrades yourselves with the documented process.

How do we test Hyperswitch migrations safely before production?

Test each migration against a restored copy of production data with the same PostgreSQL major and minor version, and time every step. Start from a snapshot taken from production, apply the migrations in the order the release requires, and record lock waits, errors and duration per file. Run the application against the migrated copy with the target router and Control Center versions, then check payment flows, refunds, webhooks and reporting. Repeat the rehearsal until the runbook is stable. Keep the test environment isolated from live processors and from real card data, and confirm the test copy is handled under your data protection and PCI DSS controls.

Can we roll back after Hyperswitch migrations have run?

Rolling back is harder once a schema change has run, because redeploying old images does not undo the database. Hyperswitch ships migrations as up.sql files, and this page does not assume down scripts exist, so confirm with the release documentation whether a reverse path is provided for each version. In practice, the reliable way back is a verified backup or a point-in-time recovery target taken just before the change, plus a tested restore procedure. Writes made after cutover may be lost if you restore, so decide the rollback threshold before the window opens. Blue/green or a parallel environment that keeps the old schema compatible can reduce this risk, and that trade-off should be planned before the upgrade.

How do PostgreSQL version upgrades interact with Hyperswitch migrations?

Treat the PostgreSQL major upgrade and the Hyperswitch schema migration as separate changes, each with its own rehearsal and rollback point. PostgreSQL 14 support runs to November 12, 2026 according to the PostgreSQL versioning policy, so teams on that major will need a plan within the year. Minor PostgreSQL releases do not change the storage format and only require replacing executables and restarting. Major upgrades can use pg_dumpall with restore, pg_upgrade, or logical replication, and logical replication can keep downtime to several seconds. Confirm that the Hyperswitch migrations run correctly on the target PostgreSQL major before combining the two changes in one window, and avoid combining them unless the rehearsal proves the sequence.

What makes a schema upgrade take longer

This table lists the factors that stretch a Hyperswitch schema upgrade from a routine step into a planned project, and what each one changes. Read it as a checklist: every row you answer with a yes or a large number adds migration review, rehearsal time or downtime planning before the production window.

DriverWhy it adds workWhat to confirm
Number of skipped versionsEach skipped release can bring its own up.sql files in the migrations directory, so the run covers every intermediate change in order.Which release you run today and which one you target, and the full list of migration folders between them.
Volume and content of migration filesLarge or table-rewriting statements take longer to run and can hold locks that block the application.Whether any migration rewrites a large table, adds an index on a big table or backfills data.
Custom SQL, views and triggers on Hyperswitch tablesSchema changes can fail or silently break your own objects that depend on renamed or dropped columns.An inventory of every view, function, trigger, report query and external job that reads Hyperswitch tables.
Database size and downtime toleranceBigger tables mean longer migrations, and a window that is too short forces a rushed or partial run.Database size, the longest acceptable write outage and whether the migration must run while traffic continues.
Replica topologyReplicas must keep up with the schema change, and read traffic routed to them can see errors while the change applies.Whether you run a primary with standbys, how replication lag is monitored and which services read from replicas.
PostgreSQL major version changeA major upgrade adds a separate data migration path, so schema work and engine work must be sequenced and tested together.Your current PostgreSQL major version and whether the target supports the Hyperswitch release you are moving to.
Connection pooling and scheduled jobsPooled connections and the Scheduler can hold sessions or run jobs during migrations, which can block DDL.Whether PgBouncer or another pooler sits in front of the database and when the Scheduler queue is drained.
Availability of a staging copyWithout a recent staging copy with production-sized data, timings and failures are only guesses until the live run.Whether a restored copy of production exists, how fresh it is and who can run the full migration against it.

Where rollback after a schema migration stops being simple

Redeploying the previous Hyperswitch images does not undo a schema migration. Once the up.sql files for the skipped versions have run against PostgreSQL, the old router and consumer binaries start against a database whose tables, columns and constraints they may not expect. Rolling back the application tier is therefore a database question as much as a deployment question. Because the Hyperswitch updates guide describes SQL changes as run against the database during an upgrade, the team should assume there is no automatic reverse path and plan one before the first migration runs. The detailed sequence for cutting back is covered in the rollback topic, so this section focuses on what must exist before that plan can work.

The restore point is the most important prerequisite. Take a logical or physical backup of the database immediately before the migration step, and confirm it can be restored into a scratch instance with the same PostgreSQL major version. Continuous archiving and point-in-time recovery, described in the PostgreSQL documentation, let you return to a moment just before the migration without depending on a single dump. Also record the exact Hyperswitch version and the list of up.sql directories that were applied, so a restore can be matched to the right application images. Ask your database team to confirm that the replica topology will not replicate a bad migration in a way you cannot unwind, and that Redis state, which is used for caching and the scheduler queue, can be flushed or rebuilt if the restored database and the cache disagree.

Decide the rollback criteria before the upgrade window opens, not during it. Useful checks include whether the router serves health checks and processes a test payment through each connector you rely on, whether webhooks and the scheduler queue drain without errors, whether the Control Center can load and reconcile recent transactions, and whether the restored database passes the row counts and recent-record checks you agreed on. Set a clear owner and a time limit for each check. If the migration itself fails partway, treat that as a separate decision from a failed application check, because a partial migration usually needs a restore rather than a redeploy. Confirm these criteria, the restore procedure and the decision owner with your team and with Juspay's release notes for the version you are taking.

How DeployOpen scopes, runs and supports your Hyperswitch schema upgrade

DeployOpen treats a Hyperswitch schema upgrade as a planned change to your PostgreSQL database, not a side effect of redeploying images. We work out which up.sql files your skipped versions require, agree the order against the application rollout, and test the run on a copy of your data before production. Everything happens in infrastructure you control.

How we scope

  • We list the current and target Hyperswitch versions and identify every up.sql file between them in the migrations directory.
  • We confirm your PostgreSQL version and whether you run a master and replica setup, since both affect the run order and backup method.
  • The written scope states which migrations, backups, rehearsals and documentation are included, and engagements are fixed-scope with a quote that follows from it.

How we build

  • We rehearse the migration run against a restored copy of production data and record timings, locks and errors for your review.
  • We set the order of database changes relative to Router, Scheduler and Control Center rollouts so old and new code never run against an unready schema.
  • We confirm a verified backup exists and a restore has been tested before any change touches the production database.

How we hand over

  • You receive a runbook listing each up.sql file applied, the command sequence, expected checks and the stop conditions for the run.
  • The handover includes the backup and restore procedure, the pre-upgrade checklist and the record of the rehearsal results.
  • Your team runs the production upgrade with us present or observing, and leaves with notes on anything that differed from the rehearsal.

How we support

  • Support is available as a retainer for upgrades to later Hyperswitch releases, including review of each release's migrations directory.
  • We can retest the migration path when your PostgreSQL major version changes, since that is a separate upgrade with its own steps.
  • Ongoing support can include backup restore tests and periodic checks that recovery procedures still match your deployment.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.