burr icon indicating copy to clipboard operation
burr copied to clipboard

Add more instructions for applying ORM migrations for S3 deployment

Open skrawcz opened this issue 9 months ago • 0 comments

Is your feature request related to a problem? Please describe. The README does not contain the steps to properly set up the DB the first time.

Describe the solution you'd like We should mention what to do -- we can use the script below for those instructions.

Describe alternatives you've considered N/A

Additional context User script that works:

#!/bin/sh

# Echo commands for debugging
set -x

# Signal handling:
trap 'echo "Caught signal, continuing anyway"' INT TERM

echo "Starting script execution"

# Create the directory structure if it doesn't exist
mkdir -p /root/.burr_server
echo "Created directory structure at /root/.burr_server"

# Initialize and apply migrations in the correct path
cd /app

echo "Running aerich init..."
aerich init -t burr.tracking.server.s3.settings.TORTOISE_ORM --location /root/.burr_server/migrations || echo "Aerich init failed or already initialized"

# Run aerich init-db with a timeout to prevent hanging
echo "Running aerich init-db..."
# Use timeout command to ensure we don't hang indefinitely
# aerich init-db will not exit or allow this script to continue without a timeout
timeout 10s aerich init-db > /tmp/aerich.log 2>&1 || echo "aerich init-db timed out or exited with non-zero status"
echo "aerich init-db result:"
cat /tmp/aerich.log

echo "Finished migration steps"

# Print database location information
echo "Database directory contents:"
ls -la /root/.burr_server/
echo "Database file exists check:"
test -f /root/.burr_server/db.sqlite3 && echo "Database file exists" || echo "Database file DOES NOT exist"

# Start the Burr server with verbose output
echo "Starting Burr server with --host 0.0.0.0 --backend s3"
burr --host 0.0.0.0 --backend s3

skrawcz avatar Mar 13 '25 04:03 skrawcz