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
@@ -483,6 +483,7 @@ class RuleConfigServiceImpl(IRuleConfigService):
SELECT id, oss_url
FROM leaudit_rule_versions
WHERE id = ANY(:version_ids)
AND deleted_at IS NULL
"""
),
{"version_ids": version_ids},
@@ -501,6 +502,7 @@ class RuleConfigServiceImpl(IRuleConfigService):
SELECT DISTINCT ON (rule_set_id) rule_set_id, id
FROM leaudit_rule_versions
WHERE rule_set_id = ANY(:rule_set_ids)
AND deleted_at IS NULL
ORDER BY rule_set_id, version_seq DESC, id DESC
"""
),
@@ -518,6 +520,7 @@ class RuleConfigServiceImpl(IRuleConfigService):
SELECT oss_url
FROM leaudit_rule_versions
WHERE id = :version_id
AND deleted_at IS NULL
LIMIT 1
"""
),
@@ -676,6 +679,7 @@ class RuleConfigServiceImpl(IRuleConfigService):
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
"""
@@ -696,6 +700,7 @@ class RuleConfigServiceImpl(IRuleConfigService):
SELECT version_seq
FROM leaudit_rule_versions
WHERE id = :version_id
AND deleted_at IS NULL
LIMIT 1
"""
),