Nobody reviews our database schema changes

Short answerKeep the schema in files that go through Git like code. DbSchema Pro saves the whole design in a .dbs model file with Git built in, so every change gets a commit, an author and a history, and Schema Synchronization turns the reviewed model into SQL. Migration tools such as Flyway do the same with numbered scripts. Free basics: review rules, a schema dump in the repo and DDL logging.

01

Keep the design in a DbSchema Pro model file in Git

DbSchema Pro saves your whole design, tables, foreign keys and diagrams, in one .dbs model file that you can also change offline. Keep that file in a Git repository: DbSchema has Git built in, so you commit, push and pull from File → Git Collaboration, and Model History in DbSchema lists every commit that changed the model and what it changed. To bring a reviewed change into a database, Schema Synchronization in DbSchema compares the model with the database and writes the SQL, which DbSchema shows before it runs.

Good if your team designs the schema together and wants one reviewed history of it

Skip if every change already reaches the database only through migration scripts

Git Collaboration · Schema Synchronization · Pricing and editions

Tool
Cost€€
EffortMedium
HelpsThis week
02

Write every change as a numbered migration file

With Flyway, each schema change is an SQL script with a version number that you keep in version control, and the Migrate command runs the scripts in the same order on every environment. Liquibase does the same with a changelog of changesets that you can store in any source control tool. Flyway's code is open source under the Apache 2.0 licence.

Good if you deploy the same schema to development, test and production

Redgate Flyway · GitHub · Liquibase

Tool
CostFree
EffortMedium
HelpsThis week
03

Use your framework's own migrations

If your app runs on Django, makemigrations packages each model change into a migration file, and the Django docs say to commit the migration and the model change together as one commit. In Rails, Active Record Migrations let you evolve your database schema over time in Ruby instead of raw SQL. The schema change then shows up in the same pull request as the code that needs it.

Good if the application owns the schema

Skip if several apps or teams write to the same database

Django · Ruby on Rails Guides

Tool
CostFree
EffortLow
HelpsThis week
04

Bring in a database consultant to set up the workflow

If several teams change the same production database and nobody owns the process, book a few days with a DBA or a database consultancy that knows your engine. Ask them to agree the migration tool, the review rule and the release steps with your team. The PostgreSQL project lists companies that offer professional services, by region.

Good if production depends on the database and changes keep colliding

PostgreSQL

Expert
Cost€€€
EffortMedium
HelpsThis month
05

Let no schema change merge without a review

Put the schema files and migrations on a protected branch in GitHub and turn on Require pull request reviews before merging, so a change needs approvals before it lands. Add the migrations folder to a CODEOWNERS file with your DBA or tech lead, and GitHub asks them for a review whenever a pull request touches it. Protected branches in private repositories need GitHub Pro, Team or Enterprise.

Good if your schema files already live in a GitHub repository

About protected branches · About code owners

Do it yourself
CostFree
EffortLow
HelpsToday
06

Commit a schema-only dump on every release

On PostgreSQL, pg_dump with --schema-only writes every object definition as SQL, without the data. On SQL Server, the Generate and Publish Scripts Wizard in SSMS scripts the objects of a database. Commit the file on each release, and git diff shows what changed in the schema since the last one.

Good if changes still happen straight in the database and you need to see them

PostgreSQL · Microsoft Learn

Do it yourself
CostFree
EffortLow
HelpsToday
07

Turn on DDL logging in the database

In PostgreSQL, set log_statement to ddl and the server logs every CREATE, ALTER and DROP statement. On SQL Server, a DDL trigger fires on CREATE, ALTER and DROP statements and can record schema changes in a table.

Good if people still have rights to change the schema by hand

PostgreSQL · Microsoft Learn

Do it yourself
CostFree
EffortLow
HelpsToday

When it's bigger than a quick fix

Bring in a DBA or a database consultancy when several teams change the same production database, when the database and the files in Git have drifted apart and nobody knows which one is right, or before a release that changes or drops large tables.

Back up the database before you run a migration or a synchronization script on production, and check that you can restore it. The PostgreSQL docs say databases with valuable data should be backed up regularly.

Backup and Restore · Professional Services

Questions people ask

How do I put a database schema in Git?

Keep it as files and commit them like code: a design model file, numbered migration scripts or a schema-only dump. Then a change gets a commit, an author and a review.

What is a database migration?

A script with a version number that makes one change to the schema. Tools such as Flyway run the scripts in the same order on every environment.

Can I see who changed the database schema?

In Git, every commit records who made it. Changes made straight in the database show up in the log if you log DDL, for example with log_statement set to ddl in PostgreSQL.

How do I make sure someone reviews schema changes?

Protect the main branch and require pull request reviews before merging. A CODEOWNERS file makes GitHub ask your DBA for a review whenever a pull request touches the schema files.

Does a schema dump include the data?

Not with pg_dump --schema-only: it writes only the object definitions, without the data.

Sources

  1. DbSchema: Git Collaboration
  2. DbSchema: Schema Synchronization
  3. DbSchema: Pricing and editions
  4. Redgate Flyway: Migrations
  5. GitHub: flyway/flyway
  6. Liquibase: What is a Changelog?
  7. Django: Migrations
  8. Ruby on Rails Guides: Active Record Migrations
  9. PostgreSQL: Professional Services
  10. GitHub Docs: About protected branches
  11. GitHub Docs: About code owners
  12. PostgreSQL: pg_dump
  13. Microsoft Learn: Generate scripts (SQL Server Management Studio)
  14. PostgreSQL: Error Reporting and Logging
  15. Microsoft Learn: DDL triggers
  16. PostgreSQL: Backup and Restore