Major tools for versioning of database structure including optional data migration are:

  • Flyway
  • Liquibase

However, the specifics of your question are beyond what existing tools offer today.

If you need to have two or more versions of some object in the database for parallel use (e.g. step-by-step migration of tables, triggers, aso.) you are better off using either:

  1. a naming scheme embedded into the objects, e.g. my_cool_function_v2 vs. my_cool_function_v3

...or:

  1. use a different database schema for every major version (if you adhere to the semantic version approach), e.g. CREATE FUNCTION my_schema_v2.my_cool_function will not collide with my_schema_v1.my_cool_function

In both cases, you usually have to manage referencing the newer version where wanted. For the second approach, this can be further simplified with the schema search_path, which you can modify to prefer a new schema containing new versions of the objects, e.g. with:

SET search_path TO my_schema_v2, my_schema_v1, public;

dynamically (useful for testing in the live system without affecting actual applications/users) and once you are confident the basics are set, include it into the PostgreSQL configuration (postgresql.conf) so that the new schema becomes standard for every new connection:

search_path = 'my_schema_v2, my_schema_v1, public'

After you have migrated all of the new objects and everything is working fine, you can remove the old my_schema_v1 from the search_path and also DROP ... CASCADE it to remove all the old objects at once.

However, one downside of the schema approach is that if you always create all objects (functions, triggers, tables, ...) in all schemas, you'll lose the benefits of it when combined with the search_path. Therefore, I would create different schemas for different objects, e.g. data_v1 for the data (tables, indexes, ...) and func_v1 for other things (functions, procedures, ...). That way you can evolve the structure independently of the data but at the same time, you can also start evolving the table structure and automatically benefit from fixes/improvements in functions but also test whether changes are forward-compatible.

Answer from Ancoron on Stack Overflow
🌐
GitHub
github.com › dolthub › doltgresql
GitHub - dolthub/doltgresql: DoltgreSQL - Version Controlled PostgreSQL · GitHub
November 1, 2023 - From the creators of Dolt, the world's first version controlled SQL database, comes Doltgres, the Postgres-flavored version of Dolt. It's a SQL database that you can branch and merge, fork and clone, push and pull just like a Git repository. Connect to your Doltgres server just like any Postgres database to read or modify schema and data.
Starred by 2K users
Forked by 69 users
Languages   Go 92.6% | PLpgSQL 6.8% | Yacc 0.4% | Shell 0.1% | JavaScript 0.1% | PLSQL 0.0%
Discussions

database - How can I perform version control of Procedures, Views, and Functions in Postgres sql - Stack Overflow
I want to do a versioning control of my database. I currently control my front-end applications through git, however I am creating my database and would like to have a versioning of my tables, fun... More on stackoverflow.com
🌐 stackoverflow.com
Versioning data in Postgres? Testing a Git like approach
This is my cheat sheet: · ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY/MM/DD HH24:MI:SS'; select count(*) from dual AS OF TIMESTAMP TO_TIMESTAMP('2010/01/01 00:00:00'); I was aware that Postgres had "time travel," but I don't know if it used this syntax, but I am aware that the feature has ... More on news.ycombinator.com
🌐 news.ycombinator.com
89
178
October 21, 2023
Why is git so cumbersome . - Stack Overflow
I have a basic understanding of how GIT works, and I am very disappointed. Doing more than one thing ALWAYS leads to trouble, in my experience. It would be great to have a place to get a large nu... More on stackoverflow.com
🌐 stackoverflow.com
April 30, 2026
Postgresql version control
What you mean about version control? version control for the table changes/ stored procedures/etc? Have you looked at https://www.liquibase.org/ More on reddit.com
🌐 r/PostgreSQL
21
10
January 23, 2020
🌐
PostgreSQL Wiki
wiki.postgresql.org › wiki › Working_with_Git
Working with Git - PostgreSQL wiki
December 23, 2024 - Since the git repository contains branches for each of the major versions of PostgreSQL, it's easy to work on the latest code from an older version instead of the current one.
Top answer
1 of 3
10

Major tools for versioning of database structure including optional data migration are:

  • Flyway
  • Liquibase

However, the specifics of your question are beyond what existing tools offer today.

If you need to have two or more versions of some object in the database for parallel use (e.g. step-by-step migration of tables, triggers, aso.) you are better off using either:

  1. a naming scheme embedded into the objects, e.g. my_cool_function_v2 vs. my_cool_function_v3

...or:

  1. use a different database schema for every major version (if you adhere to the semantic version approach), e.g. CREATE FUNCTION my_schema_v2.my_cool_function will not collide with my_schema_v1.my_cool_function

In both cases, you usually have to manage referencing the newer version where wanted. For the second approach, this can be further simplified with the schema search_path, which you can modify to prefer a new schema containing new versions of the objects, e.g. with:

SET search_path TO my_schema_v2, my_schema_v1, public;

dynamically (useful for testing in the live system without affecting actual applications/users) and once you are confident the basics are set, include it into the PostgreSQL configuration (postgresql.conf) so that the new schema becomes standard for every new connection:

search_path = 'my_schema_v2, my_schema_v1, public'

After you have migrated all of the new objects and everything is working fine, you can remove the old my_schema_v1 from the search_path and also DROP ... CASCADE it to remove all the old objects at once.

However, one downside of the schema approach is that if you always create all objects (functions, triggers, tables, ...) in all schemas, you'll lose the benefits of it when combined with the search_path. Therefore, I would create different schemas for different objects, e.g. data_v1 for the data (tables, indexes, ...) and func_v1 for other things (functions, procedures, ...). That way you can evolve the structure independently of the data but at the same time, you can also start evolving the table structure and automatically benefit from fixes/improvements in functions but also test whether changes are forward-compatible.

2 of 3
5

Hi future readers of this Q, I am the maintainer of project #yuniql: a schema versioning and migration tool than you can run with zero dependencies. In scenario described, most tools treats every change in the database as immutable or atomic change and if you need to rollback your change, it will just be another minor or major version. This way you can fully reconstruct the database anywhere, anytime and at the same time tracks the evolution of your database schema.

In yuniql, your workspace will typically be organized like this

v0.00
 + create_schema.sql
 + create_table_customers.sql
v0.01
 + create_table_custmomers_with_contact.sql
v0.02
 + create_table_custmomers_with_picture.sql

You may refer to github for getting started and samples ;) https://github.com/rdagumampan/yuniql
https://yuniql.io/docs/get-started-postgresql/

Br, Rodel

🌐
DBMS Tools
dbmstools.com › categories › version-control-tools › postgresql
8 Database Version Control for PostgreSQL - DBMS Tools
List of source version control tools . State-based tools - generate the scripts for database upgrade by comparing database structure to the model (etalon). Migration-based tools - help/assist creation of migration scripts for moving database from one version to next.
🌐
Hacker News
news.ycombinator.com › item
Versioning data in Postgres? Testing a Git like approach | Hacker News
October 21, 2023 - This is my cheat sheet: · ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY/MM/DD HH24:MI:SS'; select count(*) from dual AS OF TIMESTAMP TO_TIMESTAMP('2010/01/01 00:00:00'); I was aware that Postgres had "time travel," but I don't know if it used this syntax, but I am aware that the feature has ...
Find elsewhere
🌐
Postgres FM
postgres.fm › episodes › version-control-for-databases
Postgres FM | Version control for databases
November 4, 2022 - Nikolay and Michael discuss database schema version control — what we've seen, some options, and where we'd like to see improvements.
🌐
DBmaestro
dbmaestro.com › home › database source control – postgresql
PostgreSQL Database Source Control Solutions | DBmaestro
February 20, 2026 - This means that all of your database objects, including databases, tables, views, sequences, custom functions written in procedural languages, custom data types defined, and sequences and even selected table data (for lookup tables), will be maintained in a unified repository, and kept up-to-date automatically with any changes made by any team member on the PostgreSQL server. We empower you to monitor and control your databases through all versions and that includes:
🌐
PostgreSQL
postgresql.org › docs › current › sourcerepo.html
PostgreSQL: Documentation: 18: Appendix I. The Source Code Repository
May 14, 2026 - The PostgreSQL source code is stored and managed using the Git version control system.
🌐
Pgcon
pgcon.org › 2010 › schedule › attachments › 162_pg-git.pdf pdf
Using Git with PostgreSQL Andrew Dunstan andrew@dunslane.net
git://git.postgresql.org/git/postgresql.git · pgsql · ●My repository: – git clone git · git://github.com/oicu/pg-cvs-mirror.git · ://github.com/oicu/pg-cvs-mirror.git · pgsql · – Has clean (so far) versions of all live back · branches · Useful references · ●http://book.git-scm.com (Git Community Book) ●http://progit.org (Pro Git) ●http://oreilly.com/catalog/9780596520137/ (Version Control with Git/ Loeliger) ●http://wiki.postgresql.org/wiki/ Working_with_Git ·
🌐
GitHub
github.com › postgres › postgres
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
Starred by 21.5K users
Forked by 5.8K users
Languages   C 82.9% | PLpgSQL 7.7% | Perl 4.9% | Yacc 1.2% | Meson 0.7% | Makefile 0.6%
🌐
PostgreSQL
postgresql.org › docs › current › git.html
PostgreSQL: Documentation: 18: I.1. Getting the Source via Git
May 14, 2026 - With Git you will make a copy of the entire code repository on your local machine, so you will have access to all history and branches offline. This is the fastest and most flexible way to develop or test patches.
🌐
PostgreSQL
postgresql.org › docs › 8.1 › sourcerepo.html
PostgreSQL: Documentation: 8.1: The Source Code Repository
January 1, 2012 - The PostgreSQL source code is stored and managed using the Git version control system.
🌐
Stack Overflow
stackoverflow.com › questions › 79931371 › why-is-git-so-cumbersome
Why is git so cumbersome . - Stack Overflow
April 30, 2026 - The nice thing about git is you can generally just try it—here the confusion is that staring just temporarily shoves current changes away, and that’s (roughly) it. You can apply your stashes into any branch; how well that fits depends entirely on what was stashed.
🌐
Dockhand
dockhand.pro
Dockhand - Modern Docker Management
services: postgres: image: postgres:16-alpine restart: unless-stopped environment: POSTGRES_USER: dockhand POSTGRES_PASSWORD: changeme POSTGRES_DB: dockhand volumes: - postgres_data:/var/lib/postgresql/data dockhand: image: fnsys/dockhand:latest ports: - 3000:3000 environment: DATABASE_URL: postgres://dockhand:changeme@postgres:5432/dockhand volumes: - /var/run/docker.sock:/var/run/docker.sock - dockhand_data:/app/data depends_on: - postgres restart: unless-stopped volumes: postgres_data: dockhand_data:
🌐
DbVisualizer
dbvis.com
SQL Client and Database Management Software - DbVisualizer
DbVisualizer includes integrated support for version control using Git.
🌐
Société Générale
careers.societegenerale.com › en › job-offers › lead-software-engineer-devops-260008J6-en
Lead Software Engineer - DevOps - Bangalore, India
April 24, 2026 - We are seeking a highly capable Technical Lead with deep expertise in Big Data (Spark, Hadoop, Hive), Kubernetes platforms, Azure cloud, PostgreSQL, CI/CD (GitHub Actions/Jenkins), and DevOps automation.
🌐
Postgresql
doxygen.postgresql.org
PostgreSQL Source Code: Main Page
Loading · Searching · No Matches · PostgreSQL Source Code Documentation · The configuration used to generate this site is available here · Generated on Tue Jul 14 2026 13:13:30 for PostgreSQL Source Code by 1.9.8
🌐
GitHub
github.com › postgres
PostgreSQL · GitHub
June 4, 2026 - Mirror of the official PostgreSQL GIT repository. Note that this is just a *mirror* - we don't work with pull requests on github.
🌐
Medium
medium.com › chrisrbailey › github-actions-using-postgres-postgis-and-psql-e920a2aea7e1
GitHub Actions using Postgres/PostGIS and PSQL | by Chris Bailey | ChrisRBailey | Medium
July 8, 2020 - GitHub Actions are a nice option for CI or other automated actions on your repo. In setting up an action to run tests on some Go code, which requires a Postgres/PostGIS database, I ran into a few hiccups. This post covers these issues and my solutions, in hopes that I save others time who may have a similar need.