補上 action_plans 寫入護欄
All checks were successful
CD Pipeline / deploy (push) Successful in 57s

This commit is contained in:
OoO
2026-05-12 23:35:25 +08:00
parent caa6263872
commit bc3f9cc61a
3 changed files with 115 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
from sqlalchemy import Column, Integer, String, DateTime, Text, Boolean, ForeignKey, Index, Float
from sqlalchemy import CheckConstraint, Column, Integer, String, DateTime, Text, Boolean, ForeignKey, Index, Float
from sqlalchemy.orm import relationship
from database.models import Base
from datetime import datetime
@@ -55,6 +55,29 @@ class ActionPlan(Base):
executed_at = Column(DateTime, nullable=True)
__table_args__ = (
CheckConstraint(
"action_type IS NOT NULL OR created_by IS NOT NULL",
name="chk_action_plans_source_marker",
),
CheckConstraint(
"action_type IS NULL OR action_type IN ('auto', 'code_review_fix', 'openclaw_recommendation')",
name="chk_action_plans_action_type",
),
CheckConstraint(
"created_by IS NULL OR created_by IN ("
"'nemotron', 'openclaw', 'code_review_pipeline', "
"'ai_orchestrator', 'watcher_agent', 'agent_actions', "
"'elephant_alpha', 'manual', 'system'"
")",
name="chk_action_plans_created_by",
),
CheckConstraint(
"status IS NULL OR status IN ("
"'pending', 'approved', 'rejected', 'executed', "
"'auto_pending', 'auto_disabled', 'pending_review'"
")",
name="chk_action_plans_status",
),
Index('idx_action_plans_type', 'action_type'),
Index('idx_action_plan_sku_status', 'sku', 'status'),
Index('idx_action_plan_created', 'created_at'),