#!/usr/bin/env bash
# Create base tables from SQLAlchemy models (required before incremental migrations).
set -euo pipefail
APP_DIR="${1:-/opt/cnperp}"
cd "$APP_DIR"
source .venv/bin/activate
export PYTHONPATH="$APP_DIR"
python - <<'PY'
import app.models  # noqa: F401 — register all models
from app.core.database import Base, engine

Base.metadata.create_all(bind=engine)
print("OK: base schema created/verified from SQLAlchemy models")
PY
