P3-A: Add account_id to audit_logs model + migration (backfill via user_id → users.account_id). log_audit() gains optional account_id param with fallback SELECT to avoid churn across 40 call sites. P3-B: Add account_id to tree_shares model + migration (backfill via created_by → users.account_id). TreeShare constructor updated in trees.py. P3-C: Enable RLS on 6 remaining tables: step_ratings, step_usage_log, target_lists, session_shares, audit_logs, tree_shares. P3-D: Drop team_id from target_lists — endpoint, schema, and model now use account_id as the sole isolation key. P3-E: Append Phase 3 RLS isolation tests for all 6 tables. test_target_lists.py: fix cross-account test to use Account model (not Team) and set account_id on new User. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
941 B
Python
35 lines
941 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from uuid import UUID
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class TargetEntry(BaseModel):
|
|
label: str = Field(..., min_length=1, max_length=255)
|
|
notes: Optional[str] = Field(None, max_length=500)
|
|
|
|
|
|
class TargetListCreate(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=255)
|
|
description: Optional[str] = None
|
|
targets: list[TargetEntry] = Field(..., min_length=1)
|
|
|
|
|
|
class TargetListUpdate(BaseModel):
|
|
name: Optional[str] = Field(None, min_length=1, max_length=255)
|
|
description: Optional[str] = None
|
|
targets: Optional[list[TargetEntry]] = Field(None, min_length=1)
|
|
|
|
|
|
class TargetListResponse(BaseModel):
|
|
id: UUID
|
|
account_id: UUID
|
|
created_by: Optional[UUID]
|
|
name: str
|
|
description: Optional[str]
|
|
targets: list[TargetEntry]
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = {"from_attributes": True}
|