Spaces:
Sleeping
Sleeping
File size: 1,093 Bytes
69d639b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #!/bin/sh
set -e
BAKED_DB="/app/tracker.sqlite"
LIVE_DB="${LIVE_DB:-/data/tracker.sqlite}"
mkdir -p "$(dirname "$LIVE_DB")"
if [ ! -f "$LIVE_DB" ]; then
echo "[entrypoint] First boot: seeding $LIVE_DB from $BAKED_DB"
cp "$BAKED_DB" "$LIVE_DB"
else
echo "[entrypoint] Merging $BAKED_DB -> $LIVE_DB (preserves status / next_action)"
uv run python /app/scripts/publish_data.py "$BAKED_DB" "$LIVE_DB"
fi
# Ensure any tables the baked snapshot is missing exist. create_all() is
# idempotent and only fills in gaps — alembic stays the local source of
# truth for schema evolution; we rebuild the baked DB locally and let it
# carry the canonical schema. This guards against deploying a code change
# (e.g. a new ORM model) before the baked seed is regenerated.
echo "[entrypoint] Ensuring schema with create_all"
cd /app && uv run python -c "from opportunity_tracker.db import create_all; create_all()"
# Provision dashboard users from SEED_USERS (idempotent — only inserts missing
# usernames).
echo "[entrypoint] Seeding users"
uv run python /app/scripts/seed_users.py
exec "$@"
|