From 7b60927941c6fedfe40621414ac30d2aa50ea4db Mon Sep 17 00:00:00 2001 From: Kobe Date: Mon, 26 May 2025 15:49:22 +0200 Subject: [PATCH] fix migrations hopefully --- Dockerfile | 3 +++ entrypoint.sh | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 74c8a58..79b08dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh index d863ee0..ff87311 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 \ No newline at end of file