@startuml
skinparam backgroundColor white
skinparam defaultFontColor black
skinparam ArrowColor black
skinparam shadowing false
skinparam rectangle {
  BorderColor black
  FontColor black
}

title After: Provision SQL Self-Heals Legacy Email Columns

actor "Server Startup" as Startup
rectangle "ensure_auth_schema_provisioned" as Provision #E8F0FE
database "auth schema (athena)" as Db #E6F7EA
rectangle "sql/provision.sql" as Sql #E6F7EA
rectangle "legacy email_send_failures / emails\n(table exists with older columns)" as Legacy #FFF4CC

Startup --> Provision : boot
Provision --> Sql : execute raw SQL
Sql --> Db : CREATE TABLE IF NOT EXISTS ...
Sql --> Db : ALTER TABLE ... ADD COLUMN IF NOT EXISTS\n(resolved, resolution_note, updated_at)
Sql --> Db : ALTER TABLE emails ADD COLUMN IF NOT EXISTS\n(flow, updated_at)
Db --> Legacy : table shape upgraded in place
Sql --> Db : CREATE INDEX ... (resolved, flow)
Db --> Provision : success
Provision --> Startup : server continues startup

@enduml
