@startuml
title After: Provision SQL Creates athena-Qualified Tables
skinparam backgroundColor #FFFFFF
skinparam componentStyle rectangle
skinparam defaultFontName Consolas
skinparam defaultFontColor #000000
skinparam ArrowColor #1F2937
skinparam packageBorderColor #1F2937
skinparam packageFontColor #000000
skinparam databaseBorderColor #1F2937
skinparam databaseFontColor #000000

package "sql/provision.sql" #E8FFF0 {
  component "CREATE SCHEMA IF NOT EXISTS\nathena" as create_athena
  component "CREATE TABLE IF NOT EXISTS\nathena.users / athena.sessions / ..." as tables
  component "REFERENCES athena.users(id)\nREFERENCES athena.organization(id)" as fks
  component "CREATE INDEX ... ON\nathena.users / athena.sessions / ..." as indexes
}

package "Server Startup" #E8F1FF {
  component "ensure_auth_schema_provisioned(...)" as ensure
  component "sqlx::raw_sql(AUTH_PROVISION_SQL)" as raw_sql
}

database "PostgreSQL" as db

ensure --> raw_sql
raw_sql --> create_athena
raw_sql --> tables
raw_sql --> fks
raw_sql --> indexes
create_athena --> db : idempotent schema creation
tables --> db : creates athena.* tables
fks --> db : binds to athena.* parents
indexes --> db : indexes athena.* tables

note right of db
The file is self-contained for psql and startup use.
All auth objects are explicitly anchored under athena.
end note
@enduml
