@@ -28,10 +28,17 @@ yarn build
2828yarn legacy:build
2929
3030# Copy config files if needed
31+ if [ ! -f " $WORKSPACEDIR /ietf/settings_mysqldb.py" ]; then
32+ cp $WORKSPACEDIR /docker/configs/settings_mysqldb.py $WORKSPACEDIR /ietf/settings_mysqldb.py
33+ fi
34+ if [ ! -f " $WORKSPACEDIR /ietf/settings_postgresqldb.py" ]; then
35+ cp $WORKSPACEDIR /docker/configs/settings_postgresqldb.py $WORKSPACEDIR /ietf/settings_postgresqldb.py
36+ fi
3137
3238if [ ! -f " $WORKSPACEDIR /ietf/settings_local.py" ]; then
3339 echo " Setting up a default settings_local.py ..."
3440 cp $WORKSPACEDIR /docker/configs/settings_local.py $WORKSPACEDIR /ietf/settings_local.py
41+
3542else
3643 echo " Using existing ietf/settings_local.py file"
3744 if ! cmp -s $WORKSPACEDIR /docker/configs/settings_local.py $WORKSPACEDIR /ietf/settings_local.py; then
7380 fi
7481fi
7582
83+ # Recondition settings to make changing databases easier. (Remember that we may have developers starting with settings_local from earlier work)
84+ python docker/scripts/db-include-fix.py
85+ cat $WORKSPACEDIR /ietf/settings_local.py | sed ' s/from ietf.settings_postgresqldb import DATABASES/from ietf.settings_mysqldb import DATABASES/' > /tmp/settings_local.py && mv /tmp/settings_local.py $WORKSPACEDIR /ietf/settings_local.py
86+
7687# Create data directories
7788
7889echo " Creating data directories..."
@@ -88,7 +99,8 @@ curl -fsSL https://github.com/ietf-tools/datatracker/releases/download/baseline/
8899
89100if [ -n " $EDITOR_VSCODE " ]; then
90101 echo " Waiting for DB container to come online ..."
91- /usr/local/bin/wait-for localhost:3306 -- echo " DB ready"
102+ /usr/local/bin/wait-for db:3306 -- echo " MariaDB ready"
103+ /usr/local/bin/wait-for pgdb:5432 -- echo " Postgresql ready"
92104fi
93105
94106# Run memcached
@@ -112,7 +124,11 @@ if ietf/manage.py showmigrations | grep "\[ \] 0003_pause_to_change_use_tz"; the
112124 # This is expected to exit non-zero at the pause
113125 /usr/local/bin/python $WORKSPACEDIR /ietf/manage.py migrate --settings=settings_local || true
114126 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
127+ # This is also expected to exit non-zero at the 2nd pause
128+ echo " DEBUGGING pt 1 - this should say mysqldb"
129+ grep " DATA" $WORKSPACEDIR /ietf/settings_local.py
130+ /usr/local/bin/python $WORKSPACEDIR /ietf/manage.py migrate --settings=settings_local || true
131+ # More migrations after the move to postgres below.
116132
117133else
118134 if grep " USE_TZ" $WORKSPACEDIR /ietf/settings_local.py; then
@@ -123,6 +139,25 @@ else
123139 fi
124140fi
125141
142+ echo " DEBUGGING pt 2 - this should say mysqldb"
143+ grep " DATA" $WORKSPACEDIR /ietf/settings_local.py
144+ cat $WORKSPACEDIR /ietf/settings_local.py | sed ' s/from ietf.settings_mysqldb import DATABASES/from ietf.settings_postgresqldb import DATABASES/' > /tmp/settings_local.py && mv /tmp/settings_local.py $WORKSPACEDIR /ietf/settings_local.py
145+ echo " DEBUGGING pt 3 - this should say postgresdb"
146+ grep " DATA" $WORKSPACEDIR /ietf/settings_local.py
147+
148+ # Now transfer the migrated database from mysql to postgres unless that's already happened.
149+ if psql -U django -h pgdb -d ietf -c " \dt" 2>&1 | grep -q " Did not find any relations." ; then
150+ cat << EOF > cast.load
151+ LOAD DATABASE
152+ FROM mysql://django:RkTkDPFnKpko@db/ietf_utf8
153+ INTO postgresql://django:RkTkDPFnKpko@pgdb/ietf
154+ CAST type varchar to text drop typemod;
155+ EOF
156+ time pgloader --verbose --logfile=ietf_pgloader.run --summary=ietf_pgloader.summary cast.load
157+ rm cast.load
158+ /usr/local/bin/python $WORKSPACEDIR /ietf/manage.py migrate --settings=settings_local
159+ fi
160+
126161echo " -----------------------------------------------------------------"
127162echo " Done!"
128163echo " -----------------------------------------------------------------"
0 commit comments