Initial GeoIntel V1 foundation
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
PYTHON_BIN="${PYTHON_BIN:-}"
|
||||
|
||||
if [ -z "$PYTHON_BIN" ]; then
|
||||
for candidate in python3 python.exe python; do
|
||||
if command -v "$candidate" >/dev/null 2>&1 && "$candidate" -c "import sys" >/dev/null 2>&1; then
|
||||
PYTHON_BIN="$candidate"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -z "$PYTHON_BIN" ]; then
|
||||
echo "No usable Python interpreter found. Set PYTHON_BIN=/path/to/python and retry." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$ROOT/backend"
|
||||
|
||||
echo "== GeoIntel live migration smoke =="
|
||||
echo "Using Python: $PYTHON_BIN"
|
||||
echo "Database URL is read from backend settings / DATABASE_URL."
|
||||
|
||||
"$PYTHON_BIN" - <<'PY'
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.db.session import get_engine
|
||||
|
||||
with get_engine().connect() as connection:
|
||||
connection.execute(text("SELECT 1"))
|
||||
print("Database connection: ok")
|
||||
PY
|
||||
|
||||
"$PYTHON_BIN" -m alembic upgrade head
|
||||
|
||||
"$PYTHON_BIN" - <<'PY'
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.db.session import get_engine
|
||||
|
||||
required_objects = [
|
||||
"public.projects",
|
||||
"public.areas",
|
||||
"public.datasets",
|
||||
"public.jobs",
|
||||
"public.vector_features",
|
||||
"public.quality_checks",
|
||||
"public.metrics",
|
||||
"public.analysis_runs",
|
||||
"public.detections",
|
||||
"public.segmentations",
|
||||
"public.ix_vector_features_geometry",
|
||||
"public.ix_detections_geometry",
|
||||
"public.ix_segmentations_geometry",
|
||||
]
|
||||
|
||||
with get_engine().connect() as connection:
|
||||
postgis_version = connection.execute(text("SELECT PostGIS_Version()")).scalar()
|
||||
print(f"PostGIS version: {postgis_version}")
|
||||
|
||||
missing = [
|
||||
object_name
|
||||
for object_name in required_objects
|
||||
if connection.execute(text("SELECT to_regclass(:object_name)"), {"object_name": object_name}).scalar() is None
|
||||
]
|
||||
if missing:
|
||||
raise SystemExit(f"Missing expected migrated schema objects: {', '.join(missing)}")
|
||||
print("Required runtime schema objects: ok")
|
||||
PY
|
||||
|
||||
HEAD_COUNT="$("$PYTHON_BIN" -m alembic heads | grep -c 'head')"
|
||||
if [ "$HEAD_COUNT" -ne 1 ]; then
|
||||
echo "Expected exactly one Alembic head, found $HEAD_COUNT" >&2
|
||||
"$PYTHON_BIN" -m alembic heads >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"$PYTHON_BIN" -m alembic heads
|
||||
echo "== Live migration smoke passed =="
|
||||
Reference in New Issue
Block a user