Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use logfmt for plan modifiers #109

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

bplunkett-stripe
Copy link
Collaborator

@bplunkett-stripe bplunkett-stripe commented Feb 14, 2024

Description

  • Switch to logfmt parameters. This is @alexaub-stripe's great idea!
  • Add support for lock timeout modifiers

Motivation

Fixed #62

Testing

 ~/stripe/pg-schema-diff │ bplunkett/ov…an-modifiers  go run ./cmd/pg-schema-diff plan  --dsn "host=localhost user=postgres password=postgres database=somedb" --schema-dir ~/stripe/temp/examplesql -s 'index=1 timeout=2h lock_timeout=3m statement="SOME INSERTED STATEMENT"' --exclude-schema=public --lock-timeout-modifier='pattern="TABLE" timeout=1m' --statement-timeout-modifier='pattern="DROP" timeout=5m' --statement-timeout-modifier='pattern="DOESNT APPLY TO ANYTHING" timeout=100m'

################################ Generated plan ################################
1. DROP TABLE "some_schema"."foobar";
        -- Statement Timeout: 5m0s
        -- Lock Timeout: 1m0s
        -- Hazard DELETES_DATA: Deletes all rows in the table (and the table itself)

2. SOME INSERTED STATEMENT;
        -- Statement Timeout: 2h0m0s
        -- Lock Timeout: 3m0s
        -- Hazard IS_USER_GENERATED: This statement is user-generated

3. DROP SCHEMA "some_schema";
        -- Statement Timeout: 5m0s
        -- Lock Timeout: 3s

@bplunkett-stripe bplunkett-stripe force-pushed the bplunkett/overhaul-plan-modifiers branch from dd47517 to 602c3e6 Compare February 14, 2024 05:44
@bplunkett-stripe bplunkett-stripe force-pushed the bplunkett/overhaul-plan-modifiers branch from 602c3e6 to 01af7ba Compare February 14, 2024 05:50
@bplunkett-stripe bplunkett-stripe added the enhancement New feature or request label Feb 14, 2024
Copy link
Collaborator

@alexaub-stripe alexaub-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

"sort"
)

func mustGetAndDeleteKey(m map[string]string, key string) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Doesn't must typically imply a panic will be raised, not an error returned? Could be totally off on that and I don't have a better name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. This is not very idiomatic naming...

@bplunkett-stripe bplunkett-stripe merged commit 412b684 into main Feb 14, 2024
6 checks passed
@bplunkett-stripe bplunkett-stripe deleted the bplunkett/overhaul-plan-modifiers branch February 14, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch CLI parameters over to logfmt
2 participants