fix: 修复 WAF 规则组保存/绑定网站时报 of_waf_rule_group_bindings_pkey 冲突

This commit is contained in:
ryan
2026-06-20 21:33:46 +08:00
parent b04a358e5e
commit 99f6f3231a
6 changed files with 114 additions and 10 deletions
@@ -98,6 +98,17 @@ func up202606200006(ctx context.Context, tx *sql.Tx) error {
}
}
if dialect == dialectPostgres {
if _, err := tx.ExecContext(ctx, `
SELECT setval(
pg_get_serial_sequence('of_waf_rule_group_bindings', 'id'),
COALESCE((SELECT MAX(id) FROM of_waf_rule_group_bindings), 0)
)
`); err != nil {
return fmt.Errorf("sync of_waf_rule_group_bindings sequence failed: %w", err)
}
}
return nil
}
@@ -0,0 +1,8 @@
-- +goose Up
SELECT setval(
pg_get_serial_sequence('of_waf_rule_group_bindings', 'id'),
COALESCE((SELECT MAX(id) FROM of_waf_rule_group_bindings), 0)
);
-- +goose Down
SELECT 1;
@@ -0,0 +1,5 @@
-- +goose Up
SELECT 1;
-- +goose Down
SELECT 1;