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

feat: postgres triggers #4860

Merged
merged 112 commits into from
Jan 24, 2025
Merged

feat: postgres triggers #4860

merged 112 commits into from
Jan 24, 2025

Conversation

dieriba
Copy link
Collaborator

@dieriba dieriba commented Dec 5, 2024

PostgreSQL database trigger implementation that captures transaction events (INSERT, UPDATE, DELETE). Currently, the implementation identifies the type of transaction.

Currently working on decoding the trigger message to extract detailed information about the underlying data that caused the trigger to fire.


Important

Add PostgreSQL triggers to capture database events and trigger scripts, with backend logic and frontend UI for management.

  • Backend:
    • Implement PostgreSQL triggers to capture transaction events (INSERT, UPDATE, DELETE) in postgres_triggers module.
    • Add new models and database interactions in handler.rs and trigger.rs.
    • Introduce converter.rs and relation.rs for data conversion and relation handling.
  • Frontend:
    • Add PostgresTriggersPanel.svelte and related components for UI management of PostgreSQL triggers.
    • Update routes in +page.svelte files to include PostgreSQL triggers management.
    • Enhance DetailPageLayout.svelte to support PostgreSQL triggers in flow and script views.
  • Misc:
    • Update openapi.yaml to include new API endpoints for PostgreSQL triggers.
    • Modify Cargo.toml and Cargo.lock to include new dependencies for PostgreSQL handling.

This description was created by Ellipsis for 3248fd0. It will automatically update as commits are pushed.

Copy link
Contributor

github-actions bot commented Dec 5, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link

cloudflare-workers-and-pages bot commented Dec 7, 2024

Deploying windmill with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3248fd0
Status: ✅  Deploy successful!
Preview URL: https://6351e67e.windmill.pages.dev
Branch Preview URL: https://database-triggers.windmill.pages.dev

View logs

@rubenfiszel rubenfiszel force-pushed the main branch 5 times, most recently from e36281c to f85cf46 Compare December 9, 2024 16:57
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on a8639b7 in 1 minute and 56 seconds

More details
  • Looked at 764 lines of code in 20 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. backend/.sqlx/query-01e92a4ba3074f1dce6ec98bc6c3fad4878f48db8c17c6d58590bd5df2e3350a.json:3
  • Draft comment:
    Consider revising the 'RETURNING true' clause. Typically, 'RETURNING' is used to return specific columns or values from the updated rows. If not needed, it might be better to remove it.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The RETURNING clause appears to be intentional as the query's type signature expects a boolean return value (see type_info: "Bool"). This suggests the true return value is being used by the application code. The comment is questioning something that appears to be working as designed.
    I might be missing some SQL best practices about RETURNING clauses. Maybe there's a more idiomatic way to return a success indicator.
    Even if there are alternative approaches, the current implementation is valid and matches the expected return type. The comment doesn't provide concrete improvement suggestions.
    Delete the comment. The RETURNING clause appears intentional and matches the query's type signature. The comment questions working code without providing clear improvements.
2. backend/.sqlx/query-833a4ecec12dfe67f28016a135ffe682b023d1868a182b7cac16ce799433c257.json:3
  • Draft comment:
    Consider revising the 'RETURNING 1' clause. Typically, 'RETURNING' is used to return specific columns or values from the updated rows. If not needed, it might be better to remove it.
  • Reason this comment was not posted:
    Marked as duplicate.
3. backend/.sqlx/query-fd1db7530acf3c84b2ab696504905a50d1ed4f69629c43de7d874769c340d909.json:3
  • Draft comment:
    Consider revising the 'RETURNING 1' clause. Typically, 'RETURNING' is used to return specific columns or values from the updated rows. If not needed, it might be better to remove it.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_t8de5LvhFYPd2umG


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 2b58ca8 in 58 seconds

More details
  • Looked at 22 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. frontend/src/lib/components/triggers/TriggersEditor.svelte:15
  • Draft comment:
    The import statement was updated to PostgresTriggersPanel, which matches its usage in the code. Ensure that DatabaseTriggersPanel is not used elsewhere in the codebase if it was removed.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The import statement for PostgresTriggersPanel was updated, but the previous import DatabaseTriggersPanel is not used anywhere else in the file. This suggests that the import statement was corrected to match the actual usage in the code.

Workflow ID: wflow_OGhVDf4oLTkYoxWa


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 8fa23b1 in 1 minute and 6 seconds

More details
  • Looked at 30 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. frontend/src/lib/script_helpers.ts:634
  • Draft comment:
    The 'database' field was removed from the preprocessor function's argument, but this change is not reflected in the BUN_PREPROCESSOR_MODULE_CODE. Ensure consistency across all preprocessor definitions.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_r0VwqyWNxx6qy2Mp


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 29eb196 in 2 minutes and 1 seconds

More details
  • Looked at 633 lines of code in 20 files
  • Skipped 1 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. frontend/src/lib/components/WorkerGroup.svelte:880
  • Draft comment:
    Consider using an object instead of a Map for env_vars_static and env_vars_allowlist to ensure consistency and avoid potential issues with JSON serialization.
nconfig.env_vars_static = {}
nconfig.env_vars_allowlist = []
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
  1. The code is already treating env_vars_static like an object with object notation. 2. The Map vs object choice doesn't seem to cause any actual issues. 3. This appears to be a speculative suggestion without clear evidence of problems. 4. The code is working as is and the change would be purely preferential.
    The comment could be right that objects are more idiomatic in JavaScript/TypeScript than Maps for simple key-value storage. Maybe there are JSON serialization issues I'm not seeing.
    While objects may be more idiomatic, there's no evidence of actual problems with the current implementation. The code works fine with Maps and any serialization is handled appropriately.
    Delete the comment as it's a speculative suggestion without clear evidence of issues. The current implementation with Maps is working fine.

Workflow ID: wflow_Wo4ot33aADJHWY9c


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 68b1ddd in 1 minute and 9 seconds

More details
  • Looked at 55 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_1F6BBh7QsIvcDZGd


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on fef622c in 1 minute and 9 seconds

More details
  • Looked at 66 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. backend/windmill-api/src/variables.rs:677
  • Draft comment:
    The encrypt and decrypt functions are removed but still used in other files. Ensure these functions are defined or imported correctly to avoid compilation errors.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_MJWLaC7O07Uhtizl


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 4bd4349 in 59 seconds

More details
  • Looked at 14 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. backend/windmill-api/src/postgres_triggers/trigger.rs:278
  • Draft comment:
    The error message is logged twice, once with the path and once without. Consider logging the error message consistently with the path for clarity.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The error message logging in the listen_to_transactions function is inconsistent. The error message is logged twice, once with the path and once without. This can be improved for consistency and clarity.

Workflow ID: wflow_1rvDyARkMszkPiml


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on f8b7117 in 1 minute and 7 seconds

More details
  • Looked at 786 lines of code in 21 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_0KjL9r9JGBudqsa6


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 3248fd0 in 1 minute and 1 seconds

More details
  • Looked at 10 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. backend/.vscode/settings.json:15
  • Draft comment:
    Consider adding back the line "rust-analyzer.cargo.features": ["postgres_trigger"] if it's still relevant to the project. If not, ensure that its removal is intentional and documented.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_3NLDLyuNvqNye0ql


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@rubenfiszel rubenfiszel merged commit 316a216 into main Jan 24, 2025
8 checks passed
@rubenfiszel rubenfiszel deleted the database_triggers branch January 24, 2025 14:12
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants