fix(cnpg): add exception handlers for missing CAGGs in migration (#2065) #2512

Merged
mfreeman451 merged 1 commit from refs/pull/2512/head into main 2025-12-05 16:36:27 +00:00
mfreeman451 commented 2025-12-05 07:36:05 +00:00 (Migrated from github.com)
Owner

Imported from GitHub pull request.

Original GitHub pull request: #2066
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2066
Original created: 2025-12-05T07:36:05Z
Original updated: 2025-12-05T16:36:33Z
Original head: carverauto/serviceradar:update/cagg_fix
Original base: main
Original merged: 2025-12-05T16:36:27Z by @mfreeman451

User description

Wrap policy removal calls in exception handlers so the migration can handle cases where CAGGs don't exist or have corrupted metadata.

🤖 Generated with Claude Code

IMPORTANT: Please sign the Developer Certificate of Origin

Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include
a DCO sign-off statement indicating the DCO acceptance in one commit message. Here
is an example DCO Signed-off-by line in a commit message:

Signed-off-by: J. Doe <j.doe@domain.com>

Describe your changes

Code checklist before requesting a review

  • I have signed the DCO?
  • The build completes without errors?
  • All tests are passing when running make test?

PR Type

Bug fix


Description

  • Wrap policy removal calls in exception handlers for robustness

  • Handle missing or corrupted CAGGs gracefully during migration

  • Log errors as notices instead of failing migration

  • Prevents "cache lookup failed for function" errors


Diagram Walkthrough

flowchart LR
  A["Policy Removal Calls"] -->|Wrapped in DO blocks| B["Exception Handlers"]
  B -->|On Error| C["Log Notice Message"]
  B -->|On Success| D["Continue Migration"]
  C --> D

File Walkthrough

Relevant files
Bug fix
00000000000018_recreate_device_metrics_caggs.up.sql
Add exception handlers for CAGG policy removal                     

pkg/db/cnpg/migrations/00000000000018_recreate_device_metrics_caggs.up.sql

  • Wrapped all remove_continuous_aggregate_policy() calls in DO $$...END
    $$ blocks with exception handlers
  • Wrapped all remove_retention_policy() calls in DO $$...END $$ blocks
    with exception handlers
  • Added EXCEPTION WHEN OTHERS THEN RAISE NOTICE clauses to log errors
    without failing migration
  • Maintains original if_exists => TRUE parameters for safer execution
+42/-7   

Imported from GitHub pull request. Original GitHub pull request: #2066 Original author: @mfreeman451 Original URL: https://github.com/carverauto/serviceradar/pull/2066 Original created: 2025-12-05T07:36:05Z Original updated: 2025-12-05T16:36:33Z Original head: carverauto/serviceradar:update/cagg_fix Original base: main Original merged: 2025-12-05T16:36:27Z by @mfreeman451 --- ### **User description** Wrap policy removal calls in exception handlers so the migration can handle cases where CAGGs don't exist or have corrupted metadata. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ## IMPORTANT: Please sign the Developer Certificate of Origin Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include a [DCO sign-off statement]( https://developercertificate.org/) indicating the DCO acceptance in one commit message. Here is an example DCO Signed-off-by line in a commit message: ``` Signed-off-by: J. Doe <j.doe@domain.com> ``` ## Describe your changes ## Issue ticket number and link ## Code checklist before requesting a review - [ ] I have signed the DCO? - [ ] The build completes without errors? - [ ] All tests are passing when running make test? ___ ### **PR Type** Bug fix ___ ### **Description** - Wrap policy removal calls in exception handlers for robustness - Handle missing or corrupted CAGGs gracefully during migration - Log errors as notices instead of failing migration - Prevents "cache lookup failed for function" errors ___ ### Diagram Walkthrough ```mermaid flowchart LR A["Policy Removal Calls"] -->|Wrapped in DO blocks| B["Exception Handlers"] B -->|On Error| C["Log Notice Message"] B -->|On Success| D["Continue Migration"] C --> D ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>00000000000018_recreate_device_metrics_caggs.up.sql</strong><dd><code>Add exception handlers for CAGG policy removal</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> pkg/db/cnpg/migrations/00000000000018_recreate_device_metrics_caggs.up.sql <ul><li>Wrapped all <code>remove_continuous_aggregate_policy()</code> calls in <code>DO $$...END </code><br><code>$$</code> blocks with exception handlers<br> <li> Wrapped all <code>remove_retention_policy()</code> calls in <code>DO $$...END $$</code> blocks <br>with exception handlers<br> <li> Added <code>EXCEPTION WHEN OTHERS THEN RAISE NOTICE</code> clauses to log errors <br>without failing migration<br> <li> Maintains original <code>if_exists => TRUE</code> parameters for safer execution</ul> </details> </td> <td><a href="https://github.com/carverauto/serviceradar/pull/2066/files#diff-925f33bb594cc55187f11c4cfdfd5ab583340850fad97d939dbb57eb858ea624">+42/-7</a>&nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> </details> ___
qodo-code-review[bot] commented 2025-12-05 07:36:29 +00:00 (Migrated from github.com)
Author
Owner

Imported GitHub PR comment.

Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2066#issuecomment-3615646586
Original created: 2025-12-05T07:36:29Z

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Limited auditing: The migration logs errors as notices but does not include user identity or structured
audit details for these critical policy-removal actions.

Referred Code
    PERFORM remove_continuous_aggregate_policy('device_metrics_summary_cpu', if_exists => TRUE);
EXCEPTION WHEN OTHERS THEN
    RAISE NOTICE 'Could not remove CPU CAGG policy: %', SQLERRM;
END $$;

DO $$
BEGIN
    PERFORM remove_continuous_aggregate_policy('device_metrics_summary_disk', if_exists => TRUE);
EXCEPTION WHEN OTHERS THEN
    RAISE NOTICE 'Could not remove Disk CAGG policy: %', SQLERRM;
END $$;

DO $$
BEGIN
    PERFORM remove_continuous_aggregate_policy('device_metrics_summary_memory', if_exists => TRUE);
EXCEPTION WHEN OTHERS THEN
    RAISE NOTICE 'Could not remove Memory CAGG policy: %', SQLERRM;
END $$;

DO $$
BEGIN


 ... (clipped 18 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status:
Notice leaks detail: Using RAISE NOTICE with SQLERRM may surface internal database error text to migration
output; verify this output is not user-facing in production environments.

Referred Code
EXCEPTION WHEN OTHERS THEN
    RAISE NOTICE 'Could not remove CPU CAGG policy: %', SQLERRM;
END $$;

DO $$
BEGIN
    PERFORM remove_continuous_aggregate_policy('device_metrics_summary_disk', if_exists => TRUE);
EXCEPTION WHEN OTHERS THEN
    RAISE NOTICE 'Could not remove Disk CAGG policy: %', SQLERRM;
END $$;

DO $$
BEGIN
    PERFORM remove_continuous_aggregate_policy('device_metrics_summary_memory', if_exists => TRUE);
EXCEPTION WHEN OTHERS THEN
    RAISE NOTICE 'Could not remove Memory CAGG policy: %', SQLERRM;
END $$;

DO $$
BEGIN
    PERFORM remove_retention_policy('device_metrics_summary_cpu', if_exists => TRUE);


 ... (clipped 16 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
- Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment. Original author: @qodo-code-review[bot] Original URL: https://github.com/carverauto/serviceradar/pull/2066#issuecomment-3615646586 Original created: 2025-12-05T07:36:29Z --- ## PR Compliance Guide 🔍 <!-- https://github.com/carverauto/serviceradar/commit/debf62840781e166357cd6a3b8930888703104df --> Below is a summary of compliance checks for this PR:<br> <table><tbody><tr><td colspan='2'><strong>Security Compliance</strong></td></tr> <tr><td>🟢</td><td><details><summary><strong>No security concerns identified</strong></summary> No security vulnerabilities detected by AI analysis. Human verification advised for critical code. </details></td></tr> <tr><td colspan='2'><strong>Ticket Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary>🎫 <strong>No ticket provided </strong></summary> - [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true --> </details></td></tr> <tr><td colspan='2'><strong>Codebase Duplication Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary><strong>Codebase context is not defined </strong></summary> Follow the <a href='https://qodo-merge-docs.qodo.ai/core-abilities/rag_context_enrichment/'>guide</a> to enable codebase context checks. </details></td></tr> <tr><td colspan='2'><strong>Custom Compliance</strong></td></tr> <tr><td rowspan=4>🟢</td><td> <details><summary><strong>Generic: Meaningful Naming and Self-Documenting Code</strong></summary><br> **Objective:** Ensure all identifiers clearly express their purpose and intent, making code <br>self-documenting<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Robust Error Handling and Edge Case Management</strong></summary><br> **Objective:** Ensure comprehensive error handling that provides meaningful context and graceful <br>degradation<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Secure Logging Practices</strong></summary><br> **Objective:** To ensure logs are useful for debugging and auditing without exposing sensitive <br>information like PII, PHI, or cardholder data.<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Security-First Input Validation and Data Handling</strong></summary><br> **Objective:** Ensure all data inputs are validated, sanitized, and handled securely to prevent <br>vulnerabilities<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td rowspan=2>⚪</td> <td><details> <summary><strong>Generic: Comprehensive Audit Trails</strong></summary><br> **Objective:** To create a detailed and reliable record of critical system actions for security analysis <br>and compliance.<br> **Status:** <br><a href='https://github.com/carverauto/serviceradar/pull/2066/files#diff-925f33bb594cc55187f11c4cfdfd5ab583340850fad97d939dbb57eb858ea624R9-R47'><strong>Limited auditing</strong></a>: The migration logs errors as notices but does not include user identity or structured <br>audit details for these critical policy-removal actions.<br> <details open><summary>Referred Code</summary> ```sql PERFORM remove_continuous_aggregate_policy('device_metrics_summary_cpu', if_exists => TRUE); EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'Could not remove CPU CAGG policy: %', SQLERRM; END $$; DO $$ BEGIN PERFORM remove_continuous_aggregate_policy('device_metrics_summary_disk', if_exists => TRUE); EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'Could not remove Disk CAGG policy: %', SQLERRM; END $$; DO $$ BEGIN PERFORM remove_continuous_aggregate_policy('device_metrics_summary_memory', if_exists => TRUE); EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'Could not remove Memory CAGG policy: %', SQLERRM; END $$; DO $$ BEGIN ... (clipped 18 lines) ``` </details> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td><details> <summary><strong>Generic: Secure Error Handling</strong></summary><br> **Objective:** To prevent the leakage of sensitive system information through error messages while <br>providing sufficient detail for internal debugging.<br> **Status:** <br><a href='https://github.com/carverauto/serviceradar/pull/2066/files#diff-925f33bb594cc55187f11c4cfdfd5ab583340850fad97d939dbb57eb858ea624R10-R46'><strong>Notice leaks detail</strong></a>: Using RAISE NOTICE with SQLERRM may surface internal database error text to migration <br>output; verify this output is not user-facing in production environments.<br> <details open><summary>Referred Code</summary> ```sql EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'Could not remove CPU CAGG policy: %', SQLERRM; END $$; DO $$ BEGIN PERFORM remove_continuous_aggregate_policy('device_metrics_summary_disk', if_exists => TRUE); EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'Could not remove Disk CAGG policy: %', SQLERRM; END $$; DO $$ BEGIN PERFORM remove_continuous_aggregate_policy('device_metrics_summary_memory', if_exists => TRUE); EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'Could not remove Memory CAGG policy: %', SQLERRM; END $$; DO $$ BEGIN PERFORM remove_retention_policy('device_metrics_summary_cpu', if_exists => TRUE); ... (clipped 16 lines) ``` </details> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td align="center" colspan="2"> <!-- placeholder --> <!-- /compliance --update_compliance=true --> </td></tr></tbody></table> <details><summary>Compliance status legend</summary> 🟢 - Fully Compliant<br> 🟡 - Partial Compliant<br> 🔴 - Not Compliant<br> ⚪ - Requires Further Human Verification<br> 🏷️ - Compliance label<br> </details>
qodo-code-review[bot] commented 2025-12-05 07:37:18 +00:00 (Migrated from github.com)
Author
Owner

Imported GitHub PR comment.

Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2066#issuecomment-3615648655
Original created: 2025-12-05T07:37:18Z

PR Code Suggestions

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Consolidate repetitive blocks into one

Consolidate the six repetitive DO blocks into a single block using a FOREACH
loop to iterate over the policy names. This will make the SQL script more
concise and easier to maintain.

pkg/db/cnpg/migrations/00000000000018_recreate_device_metrics_caggs.up.sql [7-47]

 DO $$
+DECLARE
+    cagg_name TEXT;
 BEGIN
-    PERFORM remove_continuous_aggregate_policy('device_metrics_summary_cpu', if_exists => TRUE);
-EXCEPTION WHEN OTHERS THEN
-    RAISE NOTICE 'Could not remove CPU CAGG policy: %', SQLERRM;
+    FOREACH cagg_name IN ARRAY ARRAY['device_metrics_summary_cpu', 'device_metrics_summary_disk', 'device_metrics_summary_memory']
+    LOOP
+        BEGIN
+            PERFORM remove_continuous_aggregate_policy(cagg_name, if_exists => TRUE);
+        EXCEPTION WHEN OTHERS THEN
+            RAISE NOTICE 'Could not remove CAGG policy for %: %', cagg_name, SQLERRM;
+        END;
+
+        BEGIN
+            PERFORM remove_retention_policy(cagg_name, if_exists => TRUE);
+        EXCEPTION WHEN OTHERS THEN
+            RAISE NOTICE 'Could not remove retention policy for %: %', cagg_name, SQLERRM;
+        END;
+    END LOOP;
 END $$;
 
-DO $$
-BEGIN
-    PERFORM remove_continuous_aggregate_policy('device_metrics_summary_disk', if_exists => TRUE);
-EXCEPTION WHEN OTHERS THEN
-    RAISE NOTICE 'Could not remove Disk CAGG policy: %', SQLERRM;
-END $$;
-
-DO $$
-BEGIN
-    PERFORM remove_continuous_aggregate_policy('device_metrics_summary_memory', if_exists => TRUE);
-EXCEPTION WHEN OTHERS THEN
-    RAISE NOTICE 'Could not remove Memory CAGG policy: %', SQLERRM;
-END $$;
-
-DO $$
-BEGIN
-    PERFORM remove_retention_policy('device_metrics_summary_cpu', if_exists => TRUE);
-EXCEPTION WHEN OTHERS THEN
-    RAISE NOTICE 'Could not remove CPU retention policy: %', SQLERRM;
-END $$;
-
-DO $$
-BEGIN
-    PERFORM remove_retention_policy('device_metrics_summary_disk', if_exists => TRUE);
-EXCEPTION WHEN OTHERS THEN
-    RAISE NOTICE 'Could not remove Disk retention policy: %', SQLERRM;
-END $$;
-
-DO $$
-BEGIN
-    PERFORM remove_retention_policy('device_metrics_summary_memory', if_exists => TRUE);
-EXCEPTION WHEN OTHERS THEN
-    RAISE NOTICE 'Could not remove Memory retention policy: %', SQLERRM;
-END $$;
-
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies significant code repetition and proposes a valid, more concise, and maintainable solution using a loop, which improves code quality.

Low
  • More
Imported GitHub PR comment. Original author: @qodo-code-review[bot] Original URL: https://github.com/carverauto/serviceradar/pull/2066#issuecomment-3615648655 Original created: 2025-12-05T07:37:18Z --- ## PR Code Suggestions ✨ <!-- debf628 --> Explore these optional code suggestions: <table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>General</td> <td> <details><summary>Consolidate repetitive blocks into one</summary> ___ **Consolidate the six repetitive <code>DO</code> blocks into a single block using a <code>FOREACH</code> <br>loop to iterate over the policy names. This will make the SQL script more <br>concise and easier to maintain.** [pkg/db/cnpg/migrations/00000000000018_recreate_device_metrics_caggs.up.sql [7-47]](https://github.com/carverauto/serviceradar/pull/2066/files#diff-925f33bb594cc55187f11c4cfdfd5ab583340850fad97d939dbb57eb858ea624R7-R47) ```diff DO $$ +DECLARE + cagg_name TEXT; BEGIN - PERFORM remove_continuous_aggregate_policy('device_metrics_summary_cpu', if_exists => TRUE); -EXCEPTION WHEN OTHERS THEN - RAISE NOTICE 'Could not remove CPU CAGG policy: %', SQLERRM; + FOREACH cagg_name IN ARRAY ARRAY['device_metrics_summary_cpu', 'device_metrics_summary_disk', 'device_metrics_summary_memory'] + LOOP + BEGIN + PERFORM remove_continuous_aggregate_policy(cagg_name, if_exists => TRUE); + EXCEPTION WHEN OTHERS THEN + RAISE NOTICE 'Could not remove CAGG policy for %: %', cagg_name, SQLERRM; + END; + + BEGIN + PERFORM remove_retention_policy(cagg_name, if_exists => TRUE); + EXCEPTION WHEN OTHERS THEN + RAISE NOTICE 'Could not remove retention policy for %: %', cagg_name, SQLERRM; + END; + END LOOP; END $$; -DO $$ -BEGIN - PERFORM remove_continuous_aggregate_policy('device_metrics_summary_disk', if_exists => TRUE); -EXCEPTION WHEN OTHERS THEN - RAISE NOTICE 'Could not remove Disk CAGG policy: %', SQLERRM; -END $$; - -DO $$ -BEGIN - PERFORM remove_continuous_aggregate_policy('device_metrics_summary_memory', if_exists => TRUE); -EXCEPTION WHEN OTHERS THEN - RAISE NOTICE 'Could not remove Memory CAGG policy: %', SQLERRM; -END $$; - -DO $$ -BEGIN - PERFORM remove_retention_policy('device_metrics_summary_cpu', if_exists => TRUE); -EXCEPTION WHEN OTHERS THEN - RAISE NOTICE 'Could not remove CPU retention policy: %', SQLERRM; -END $$; - -DO $$ -BEGIN - PERFORM remove_retention_policy('device_metrics_summary_disk', if_exists => TRUE); -EXCEPTION WHEN OTHERS THEN - RAISE NOTICE 'Could not remove Disk retention policy: %', SQLERRM; -END $$; - -DO $$ -BEGIN - PERFORM remove_retention_policy('device_metrics_summary_memory', if_exists => TRUE); -EXCEPTION WHEN OTHERS THEN - RAISE NOTICE 'Could not remove Memory retention policy: %', SQLERRM; -END $$; - ``` - [ ] **Apply / Chat** <!-- /improve --apply_suggestion=0 --> <details><summary>Suggestion importance[1-10]: 6</summary> __ Why: The suggestion correctly identifies significant code repetition and proposes a valid, more concise, and maintainable solution using a loop, which improves code quality. </details></details></td><td align=center>Low </td></tr> <tr><td align="center" colspan="2"> - [ ] More <!-- /improve --more_suggestions=true --> </td><td></td></tr></tbody></table>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
carverauto/serviceradar!2512
No description provided.