doc/development/database/database_upgrade_ddl_lock.md
During major PostgreSQL upgrades on GitLab.com, DDL (Data Definition Language) changes are temporarily blocked to prevent conflicts with the upgrade process. GitLab.com uses logical replication for PostgreSQL upgrades, replicating data between different major versions to achieve zero-downtime upgrades. During the upgrade window, new DDL changes can break the replication.
Instead of using a hard Production Change Lock (PCL) that blocks all deployments, a targeted lock prevents only database schema changes from being merged.
This approach allows GitLab to continue releasing other changes while protecting the database upgrade process from breaking schema modifications.
The DDL lock is configured in config/database_change_lock.yml and enforced by a
Danger check that runs in CI/CD pipelines. The configuration includes:
db/structure.sql are automatically blocked by Danger.The same config/database_change_lock.yml file also blocks new
post-deployment migrations (PDMs) when a lock entry
has block_level: only_pdm. This is intended for soft Production Change Locks
during which PDMs are not executed.
PDMs are not executed during a soft PCL. Merging new PDMs anyway grows the backlog that runs once the PCL ends, increasing the size and risk of that post-PCL migration run.
When block_level: only_pdm is set:
db/post_migrate/ or ee/db/post_migrate/ are blocked.only_pdm lock.The default block_level is only_ddl, which matches the original PostgreSQL upgrade behavior.
When a lock is configured and active:
If your merge request contains DDL changes and is affected by an upgrade lock:
You can still merge your changes. The Danger check displays a warning message indicating:
Consider merging your changes before the lock begins, or plan to wait until after the lock expires.
You must wait until the lock expires. The Danger check fails with an error message.
After the lock ends: