fix: purge rule version history after reset import

This commit is contained in:
wren
2026-05-21 22:22:25 +08:00
parent 1f1bccf3b3
commit 18717e8276
5 changed files with 89 additions and 3 deletions
@@ -237,6 +237,7 @@ class RuleServiceImpl(IRuleService):
rv.published_at
FROM leaudit_rule_versions rv
WHERE rv.rule_set_id = :rule_set_id
AND rv.deleted_at IS NULL
ORDER BY rv.version_seq DESC, rv.id DESC
"""
),
@@ -258,6 +259,7 @@ class RuleServiceImpl(IRuleService):
JOIN leaudit_rule_sets rs ON rs.id = rv.rule_set_id
WHERE rs.rule_type = :rule_type
AND rs.deleted_at IS NULL
AND rv.deleted_at IS NULL
ORDER BY rv.version_seq DESC, rv.id DESC
"""
),
@@ -281,6 +283,7 @@ class RuleServiceImpl(IRuleService):
FROM leaudit_rule_versions rv
JOIN leaudit_rule_sets rs ON rs.id = rv.rule_set_id
WHERE rv.id = :version_id
AND rv.deleted_at IS NULL
LIMIT 1
"""
),
@@ -1087,6 +1090,7 @@ class RuleServiceImpl(IRuleService):
published_at
FROM leaudit_rule_versions
WHERE id = :version_id
AND deleted_at IS NULL
LIMIT 1
"""
),
@@ -1102,6 +1106,7 @@ class RuleServiceImpl(IRuleService):
SELECT id
FROM leaudit_rule_versions
WHERE rule_set_id = :rule_set_id
AND deleted_at IS NULL
ORDER BY version_seq DESC, id DESC
LIMIT 1
"""