@startuml
title After: Self-Healing Writes athena.audit_log_ddl (If Table Exists)
skinparam backgroundColor #FAFAFA
skinparam componentStyle rectangle
skinparam defaultFontName Consolas

package "Startup" #E8FFF0 {
  component "ensure_auth_schema_provisioned" as heal
  component "pre-check: healing required?" as checkHeal
  component "pre-check: athena.audit_log_ddl exists?" as checkAudit
  component "CREATE SCHEMA IF NOT EXISTS" as createSchema
  component "sql/provision.sql" as provision
  component "record_self_heal_audit_log" as record
}

database "PostgreSQL" as db

heal --> checkHeal
heal --> checkAudit
heal --> createSchema
createSchema --> db
heal --> provision
provision --> db
checkHeal --> record : yes
checkAudit --> record : exists
record --> db : INSERT INTO athena.audit_log_ddl

note bottom of record
Writes only when:
1) healing actually happened
2) athena.audit_log_ddl existed beforehand
Startup remains non-fatal if audit insert fails.
end note
@enduml
