pglockanalyze 0.0.2

See what PostgreSQL locks your migrations acquired
docs.rs failed to build pglockanalyze-0.0.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: pglockanalyze-0.0.4

pglockanalyze Build Status Latest Version

See what PostgreSQL locks your migrations acquired.

For use in CI and development environments.

Status

This software is experimental and under development.

Rationale

Understanding the locks your migrations will acquire is crucial to avoiding downtime in production traffic. Tools like the official Postgres docs and strong_migrations are invaluable; however, reasoning your way through complex DDL statements is not always practical.

pglockanalyze complements these tools by executing your migrations against a test database (that you have to set up) and dynamically identifying the locks acquired at runtime. It is meant to be integrated to CI pipelines and/or development workflows.

Installation

You can install pglockanalyze using cargo:

$ cargo install pglockanalyze

We do not distribute binaries yet, but we may do so in the future.

Usage

$ echo 'ALTER TABLE users ALTER COLUMN name SET NOT NULL' | pglockanalyze --db 'postgres://foo@bar'
ALTER TABLE users ALTER COLUMN name SET NOT NULL
	acquired `AccessExclusive` lock on relation `users` (oid=16386)

Use --help to see all options:

Usage: pglockanalyze [OPTIONS] --db <postgres connection string> [INPUT]

Arguments:
  [INPUT]  The DDL statements to analyze. If not provided or is -, read from standard input [default: -]

Options:
      --db <postgres connection string>
          The database to connect to
  -f, --format <FORMATTER>
          The output format of the analysis [default: plain] [possible values: plain, json]
      --distinct-transactions
          Execute each statement in its own transaction. By default all statements are executed in a single transaction. Implies --commit
      --commit
          Commit the transactions. By default they are rolled back
  -h, --help
          Print help
  -V, --version
          Print version

License

pglockanalyze is licensed under the Apache 2.0 license.