Skip to content

CICD-317 · Migration lock management ​

Encyclopedia · Database delivery and migration · All snippets

Previous · CICD-316 · Next · CICD-318

1. Where it fits ​

  • Placement db/apply.sql transaction fragment.
  • Prerequisites disposable database, migration tools and a scoped database role.
  • Platforms local-lab.

2. Copy the snippet ​

sql
SET LOCAL lock_timeout = '5s';
SELECT pg_advisory_xact_lock(981023);

3. How it works ​

Use the database connection and transaction boundary called out below. The SQL statement controls the actual schema or data change.

4. Verify the result ​

Run inside the same transaction and database connection as the DDL. Use a centrally allocated lock key and retry carefully after timeout.

Validation untested. Status definitions.