@startuml
title After: Self-Heal Always Creates Athena Then Runtime Schema
skinparam backgroundColor #FFFFFF
skinparam defaultFontColor #000000
skinparam ArrowColor #1F2937
skinparam componentStyle rectangle
skinparam defaultFontName Consolas

package "Server Startup" #E8FFF0 {
  component "build_sqlx_adapter(...)" as build #E8FFF0
  component "ensure_auth_schema_provisioned(...)" as ensure #E8FFF0
  component "schema_bootstrap_targets(auth_schema)\n=> [athena, <auth_schema>] (deduped)" as targets #F0FFF4
  component "CREATE SCHEMA IF NOT EXISTS\nathena" as create_athena #EAF7FF
  component "CREATE SCHEMA IF NOT EXISTS\n<auth_schema>" as create_auth #EAF7FF
  component "SET LOCAL search_path\nTO <auth_schema>" as set_path #EAF2FF
  component "apply sql/provision.sql\n(rewritten to <auth_schema>)" as provision #EAF2FF
}

database "PostgreSQL" as db #FFFCEB

build --> ensure
ensure --> targets
targets --> create_athena
create_athena --> db
targets --> create_auth
create_auth --> db
ensure --> set_path
set_path --> db
ensure --> provision
provision --> db

note right of ensure #E8FFF0
Startup now guarantees athena exists first.
Table provisioning can run even when the database starts without schemas.
end note
@enduml
