Deploy PostgreSQL Migration Service
Migrate data from a standalone Postgres instance to a cluster
pg-migrate-ha
Just deployed
This template deploys a script which migrates your Postgres databases from a standalone instance to a Highly Available Cluster.
Optionally, it can also enable replication between the Standalone and the Cluster, to facilitate an incremental migration.
How to use
Deploy this template into the Railway project that contains the standalone Postgres instance and the Postgres cluster. If needed, you can deploy a cluster from the HA Postgres template.
Set the required variables:
PRIMARY_URL- URL of the primary node in your cluster. If deployed from the HA Postgres template, it is likelypg-0but you can check by queryingshow pool_nodes;using psql against the cluster (via PgPool).STANDALONE_URL- URL of the standalone Postgres instance.
You can either hardcode the values, or use reference variables.
Enable replication
The script can optionally enable replication between the Standalone and the Cluster, to facilitate an incremental cutover to the Cluster. To leverage this function, you should set the required environment variables for enabling replication:
ENABLE_REPLICATION- Set to "true" (lowercase)RAILWAY_API_TOKEN- Your Railway API token. Required to restart the Standalone instance to apply the required configuration.
Template Content
pg-migrate-ha
railwayapp-templates/pg-migrate-haPRIMARY_URL
DATABASE_URL of the PRIMARY node.
STANDALONE_URL
DATABASE_URL of the standalone node.
