fix migrations hopefully

This commit is contained in:
2025-05-26 15:49:22 +02:00
parent 0bf66d4430
commit 7b60927941
2 changed files with 19 additions and 2 deletions

View File

@@ -16,6 +16,9 @@ RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
COPY . .
# Create migrations directory if it doesn't exist
RUN mkdir -p migrations/versions
# Make entrypoint script executable
RUN chmod +x entrypoint.sh

View File

@@ -7,17 +7,31 @@ while ! nc -z db 5432; do
done
echo "Database is ready!"
# Initialize the database
# Initialize migrations if they don't exist
if [ ! -d "migrations" ]; then
echo "Initializing database migrations..."
flask db init
fi
# Create and apply migrations
echo "Creating and applying database migrations..."
flask db migrate -m "Initial migration"
flask db upgrade
# Create default site settings if they don't exist
echo "Creating default site settings..."
python3 -c "
from app import create_app
from models import SiteSettings, db
app = create_app()
with app.app_context():
SiteSettings.get_settings()
try:
settings = SiteSettings.get_settings()
print('Default site settings created successfully')
except Exception as e:
print(f'Error creating site settings: {e}')
"
# Start the application
echo "Starting application..."
exec gunicorn --bind 0.0.0.0:5000 app:app