Skip to content

Disable soft deletion of AttributeOverride#449

Merged
Starosdev merged 2 commits intoStarosdev:masterfrom
ryd994:ryd994/fix_readd_override
Apr 9, 2026
Merged

Disable soft deletion of AttributeOverride#449
Starosdev merged 2 commits intoStarosdev:masterfrom
ryd994:ryd994/fix_readd_override

Conversation

@ryd994
Copy link
Copy Markdown

@ryd994 ryd994 commented Apr 9, 2026

Summary

Soft deletion of AttributeOverride leaves the record in database. New records can't be added because of the unique constraint.
The issue can be fixed either by changing deletion code to explicitly hard-delete, or by removing DeletedAt field, which disables implicit soft delete in GORM.

I don't see any reasons for soft deletion, therefore this PR removes DeletedAt field.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or infrastructure change

Related Issues

Fixes #447

Changes Made

  • Remove DeletedAt field of AttributeOverride
  • Add migration for the AttributeOverride table in database
  • Fix existing test failure GetBool("web.mqtt.enabled") : Unspecified value in test.
  • Fix existing test failure TestGetDevicesSummaryRoute_Nvme : DeviceID is no longer the WWN. Should be the hash from Generate function.

Testing

  • I have tested this locally
  • I have added/updated tests that prove my fix/feature works
    None of the existing tests validates database insert/delete/constraint. Please advice how the test should be performed.
  • All existing tests pass
    (and fixed some)

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my code
  • I have commented my code where necessary (particularly complex areas)
  • I have updated the documentation if needed
    Not needed.
  • My changes generate no new warnings
  • No console.log, debug statements, or commented-out code

Screenshots (if applicable)

No visual change.

Additional Notes

Could anyone help me understand why DeletedAt was used in the first place? Is there any reason for AttributeOverride to soft delete?

@ryd994 ryd994 requested a review from Starosdev as a code owner April 9, 2026 05:50
@Starosdev
Copy link
Copy Markdown
Owner

No intentional reason for soft-delete. The original model used gorm.Model which bundles DeletedAt automatically. It was just the GORM default, not a deliberate design choice. Removing it is the right fix.

@Starosdev Starosdev merged commit 808d4d2 into Starosdev:master Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Can't re-add attribute override after delete

2 participants