Skip to content

Commit 7ea3e18

Browse files
authored
fix: move check and migrate to prepare.js for diff/cli builds. (ietf-tools#4398)
1 parent 4bcf896 commit 7ea3e18

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

dev/diff/cli.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,6 @@ async function main () {
700700
task: async (subctx, subtask) => {
701701
await executeCommand(subtask, containers.appSource, ['bash', '-c', 'chmod +x ./dev/diff/prepare.sh'])
702702
await executeCommand(subtask, containers.appSource, ['bash', './dev/diff/prepare.sh'])
703-
subtask.title = `Preparing source Datatracker instance - Running checks...`
704-
await executeCommand(subtask, containers.appSource, ['bash', '-c', './ietf/manage.py check'])
705-
subtask.title = `Preparing source Datatracker instance - Applying migrations...`
706-
await executeCommand(subtask, containers.appSource, ['bash', '-c', './ietf/manage.py migrate'])
707703
subtask.title = `Source Datatracker instance is now ready.`
708704
}
709705
},
@@ -712,10 +708,6 @@ async function main () {
712708
task: async (subctx, subtask) => {
713709
await executeCommand(subtask, containers.appTarget, ['bash', '-c', 'chmod +x ./dev/diff/prepare.sh'])
714710
await executeCommand(subtask, containers.appTarget, ['bash', './dev/diff/prepare.sh'])
715-
subtask.title = `Run target Datatracker instance - Running checks...`
716-
await executeCommand(subtask, containers.appTarget, ['bash', '-c', './ietf/manage.py check'])
717-
subtask.title = `Run target Datatracker instance - Applying migrations...`
718-
await executeCommand(subtask, containers.appTarget, ['bash', '-c', './ietf/manage.py migrate'])
719711
subtask.title = `Run target Datatracker instance - Starting server...`
720712
executeCommand(subtask, containers.appTarget, ['bash', '-c', './ietf/manage.py runserver 0.0.0.0:8000 --settings=settings_local'])
721713
subtask.title = `Run target Datatracker instance - Waiting for server to accept connections...`

dev/diff/prepare.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,24 @@ yarn legacy:build
1212
echo "Creating data directories..."
1313
chmod +x ./docker/scripts/app-create-dirs.sh
1414
./docker/scripts/app-create-dirs.sh
15+
16+
./ietf/manage.py check
17+
if ./ietf/manage.py showmigrations | grep "\[ \] 0003_pause_to_change_use_tz"; then
18+
if grep "USE_TZ" ./ietf/settings_local.py; then
19+
cat ./ietf/settings_local.py | sed 's/USE_TZ.*$/USE_TZ = False/' > /tmp/settings_local.py && mv /tmp/settings_local.py ./ietf/settings_local.py
20+
else
21+
echo "USE_TZ = False" >> ./ietf/settings_local.py
22+
fi
23+
# This is expected to exit non-zero at the pause
24+
/usr/local/bin/python ./ietf/manage.py migrate || true
25+
cat ./ietf/settings_local.py | sed 's/USE_TZ.*$/USE_TZ = True/' > /tmp/settings_local.py && mv /tmp/settings_local.py ./ietf/settings_local.py
26+
/usr/local/bin/python ./ietf/manage.py migrate
27+
28+
else
29+
if grep "USE_TZ" ./ietf/settings_local.py; then
30+
cat ./ietf/settings_local.py | sed 's/USE_TZ.*$/USE_TZ = True/' > /tmp/settings_local.py && mv /tmp/settings_local.py ./ietf/settings_local.py
31+
else
32+
echo "USE_TZ = True" >> ./ietf/settings_local.py
33+
/usr/local/bin/python ./ietf/manage.py migrate
34+
fi
35+
fi

0 commit comments

Comments
 (0)