Skip to content

Commit 4bcf896

Browse files
authored
fix: manage initial container migration more carefully. (ietf-tools#4396)
1 parent f7f0ca9 commit 4bcf896

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

docker/scripts/app-init.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,27 @@ echo "Starting memcached..."
101101
echo "Running initial checks..."
102102
/usr/local/bin/python $WORKSPACEDIR/ietf/manage.py check --settings=settings_local
103103

104-
/usr/local/bin/python $WORKSPACEDIR/ietf/manage.py migrate --settings=settings_local || (echo "USE_TZ = True" >> $WORKSPACEDIR/ietf/settings_local.py; /usr/local/bin/python $WORKSPACEDIR/ietf/manage.py migrate --settings=settings_local)
104+
# Migrate, adjusting to what the current state of the underlying database might be:
105+
106+
if ietf/manage.py showmigrations | grep "\[ \] 0003_pause_to_change_use_tz"; then
107+
if grep "USE_TZ" $WORKSPACEDIR/ietf/settings_local.py; then
108+
cat $WORKSPACEDIR/ietf/settings_local.py | sed 's/USE_TZ.*$/USE_TZ = False/' > /tmp/settings_local.py && mv /tmp/settings_local.py $WORKSPACEDIR/ietf/settings_local.py
109+
else
110+
echo "USE_TZ = False" >> $WORKSPACEDIR/ietf/settings_local.py
111+
fi
112+
# This is expected to exit non-zero at the pause
113+
/usr/local/bin/python $WORKSPACEDIR/ietf/manage.py migrate --settings=settings_local || true
114+
cat $WORKSPACEDIR/ietf/settings_local.py | sed 's/USE_TZ.*$/USE_TZ = True/' > /tmp/settings_local.py && mv /tmp/settings_local.py $WORKSPACEDIR/ietf/settings_local.py
115+
/usr/local/bin/python $WORKSPACEDIR/ietf/manage.py migrate --settings=settings_local
116+
117+
else
118+
if grep "USE_TZ" $WORKSPACEDIR/ietf/settings_local.py; then
119+
cat $WORKSPACEDIR/ietf/settings_local.py | sed 's/USE_TZ.*$/USE_TZ = True/' > /tmp/settings_local.py && mv /tmp/settings_local.py $WORKSPACEDIR/ietf/settings_local.py
120+
else
121+
echo "USE_TZ = True" >> $WORKSPACEDIR/ietf/settings_local.py
122+
/usr/local/bin/python $WORKSPACEDIR/ietf/manage.py migrate --settings=settings_local
123+
fi
124+
fi
105125

106126
echo "-----------------------------------------------------------------"
107127
echo "Done!"

0 commit comments

Comments
 (0)