This commit is contained in:
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user