feat(cli): add -lock flag for session and table locking#1015
feat(cli): add -lock flag for session and table locking#1015akshah123 wants to merge 1 commit intopressly:mainfrom
Conversation
Add CLI support for migration locking to prevent concurrent migrations from running simultaneously. This addresses community requests from issues pressly#335 and pressly#972. New features: - Add -lock flag with modes: none, session, table - Add GOOSE_LOCK environment variable support - Session locking uses PostgreSQL advisory locks (pg_advisory_lock) - Table locking uses distributed table-based locks with heartbeat When locking is enabled, the CLI uses the Provider API which supports the SessionLocker and Locker interfaces. This ensures proper integration with the existing lock package. Fail-fast behavior: If a user requests locking for a driver that doesn't support it, the CLI exits with a clear error message. Currently only PostgreSQL (postgres, pgx, redshift) supports both lock modes. Usage examples: goose -lock=session postgres "..." up GOOSE_LOCK=table goose postgres "..." up
|
is there a reason to not make locking the default for supported drivers? |
I believe even without CLI, locking is not enabled by default. Users have to explicitly add it with If maintainers wish to make this default, I can update my PR accordingly. |
|
Locking will be the default in /v4 of this library. This feature didn't always exist, and for historical reasons, serialization was managed manually (no need for locking). But since then, it's become apparent that locking in the app is the way to go and has worked quite well for many users. |
|
@mfridman to remove any ambiguity, are you suggesting I should make it a default in this PR or that not to do so until v4? |
|
Also, would love your thoughts on whether this is something community would like to have and if yes any suggestions on what I should address so that this can be merged. |
Add CLI support for migration locking to prevent concurrent migrations from running simultaneously. This addresses community requests from issues #335 and #972.
New features:
When locking is enabled, the CLI uses the Provider API which supports the SessionLocker and Locker interfaces. This ensures proper integration with the existing lock package.
Fail-fast behavior: If a user requests locking for a driver that doesn't support it, the CLI exits with a clear error message. Currently only PostgreSQL (postgres, pgx, redshift) supports both lock modes.
Usage examples:
goose -lock=session postgres "..." up
GOOSE_LOCK=table goose postgres "..." up