feat: implement user data schema and API endpoints
- Add Alembic migration setup with async configuration - Create 16 user data models (users, decks, cards, replays, etc.) - Implement comprehensive API endpoints with JWT auth - Add replay, card collection, group, network, preferences, and activity log routers - Include API documentation and migration test plan - Update Dockerfile to run migrations on startup
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# Run Alembic migrations with database connectivity check
|
||||
|
||||
set -e
|
||||
|
||||
echo "Running Alembic migrations..."
|
||||
|
||||
# Check if database is reachable
|
||||
echo "Checking database connectivity..."
|
||||
until python -c "
|
||||
import asyncio
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
|
||||
async def check():
|
||||
engine = create_async_engine('postgresql+asyncpg://mtgonline_user:mtgonline_password@postgres:5432/mtgonline')
|
||||
async with engine.connect() as conn:
|
||||
await conn.execute(sqlalchemy.text('SELECT 1'))
|
||||
await engine.dispose()
|
||||
print('Database connection successful')
|
||||
|
||||
import sqlalchemy
|
||||
asyncio.run(check())
|
||||
" 2>/dev/null; do
|
||||
echo "Waiting for database to be ready..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Run migrations
|
||||
echo "Applying migrations..."
|
||||
alembic upgrade head
|
||||
|
||||
echo "Migrations completed successfully!"
|
||||
Reference in New Issue
Block a user