Alembix fixes

This commit is contained in:
James Pattinson
2025-12-18 14:59:25 +00:00
parent d183678282
commit 8513a7bb0f
3 changed files with 33 additions and 15 deletions

View File

@@ -125,17 +125,23 @@ elif [ $DB_STATE -eq 0 ]; then
echo "Checking for pending migrations..."
cd /app
# Get current and head revisions
CURRENT=$(alembic current 2>/dev/null | grep -o '[a-f0-9]\{12\}' | head -1 || echo "none")
HEAD=$(alembic heads 2>/dev/null | grep -o '[a-f0-9]\{12\}' | head -1 || echo "none")
# Get current and head revisions (handle both hash and named revisions)
CURRENT=$(alembic current 2>/dev/null | tail -1 | awk '{print $NF}' || echo "none")
HEAD=$(alembic heads 2>/dev/null | tail -1 | awk '{print $NF}' || echo "none")
echo " Current: $CURRENT"
echo " Target: $HEAD"
if [ "$CURRENT" != "$HEAD" ] && [ "$HEAD" != "none" ]; then
echo "✓ Pending migrations detected"
echo " Current: $CURRENT"
echo " Target: $HEAD"
echo "Applying migrations..."
alembic upgrade head
echo "✓ Migrations applied"
if [ $? -eq 0 ]; then
echo "✓ Migrations applied successfully"
else
echo "✗ Migration failed"
exit 1
fi
else
echo "✓ Database is up to date"
fi