Files
servesync-demo/backend/start.sh

30 lines
718 B
Bash

#!/bin/bash
set -e
echo "Waiting for database..."
sleep 3
echo "Resetting database (full schema drop)..."
python -c "
from app.database import engine
from app.models import Base
from sqlalchemy import text
with engine.connect() as conn:
conn.execute(text('DROP SCHEMA public CASCADE'))
conn.execute(text('CREATE SCHEMA public'))
conn.execute(text('GRANT ALL ON SCHEMA public TO servesync'))
conn.execute(text('GRANT ALL ON SCHEMA public TO public'))
conn.commit()
print('Schema dropped.')
Base.metadata.create_all(bind=engine)
print('New schema created.')
"
echo "Seeding data..."
python /app/seed.py
echo "Starting server..."
exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 1