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
"""
),
@@ -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
"""