File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22.git /
33* .sqlite3
44venv
5+ .tmp /
56
67server /.env
78server /static
Original file line number Diff line number Diff line change 11* .swp
2+ .tmp /
23
34venv /
45__pycache__ /
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ console_command = '/code/manage.py shell'
1010[build ]
1111
1212[deploy ]
13- # Run the database migration manually after deploy if using volume storage, since release_command does not have access to fly.io storage volumes
13+ # NOTE: Run database migrations manually after deploy if using volume storage, since release_command does not have access to fly.io storage volumes
1414# Reference: https://community.fly.io/t/using-sqlite-from-persistent-volume-for-django-application/16206/3
1515# release_command = 'python manage.py migrate --noinput'
1616
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3+
4+ # Specify the target fly.toml configuration file
5+ function specify_target_fly_toml() {
6+ # Move currently active fly.toml configuration file to local tmp directory
7+ if [ -f fly.toml ]; then
8+ mkdir -p .tmp
9+ mv fly.toml .tmp/fly.toml
10+ fi
11+
12+ # Copy target fly.toml configuration file to project root directory
13+ cp -p ./scripts/configs/fly-sqlite.toml fly.toml
14+ }
15+ specify_target_fly_toml
16+
17+
318# Create app without launching
419yes n | fly launch --vm-memory 512 --ha=false --no-db --now --copy-config --build-only
520
621# Set database location
722flyctl secrets set DATABASE_URL=sqlite:////data/db.sqlite3
823
24+ # Use gsed on macOS
25+ SED_CMD=" sed"
26+ if [[ " $OSTYPE " == " darwin" * ]]; then
27+ SED_CMD=" gsed"
28+ fi
29+
30+ # HACKY FIX: flyctl will override this change that we manually made in the fly.toml file :/.
31+ # Update fly.toml to disable release_command and migrate in a separate step
32+ # NOTE: Run database migrations manually after deploy if using volume storage, since release_command does not have access to fly.io storage volumes
33+ # Reference: https://community.fly.io/t/using-sqlite-from-persistent-volume-for-django-application/16206/3
34+ $SED_CMD -i " s| release_command = 'python manage.py migrate --noinput'|# release_command = 'python manage.py migrate --noinput'|g" fly.toml
35+
36+
937# Launch app
1038fly deploy
1139
1240# Run migrations
1341fly ssh console -C ' python manage.py migrate'
42+
43+ # Restore existing fly.toml
44+ mv .tmp/fly.toml fly.toml
You can’t perform that action at this time.
0 commit comments