Instructions on recreating the database with data imported from all periods.
Requirements:
- application must be installed/deployed
- must have credentials to the SQL Server for 2014-2021 and set in the environment variables
(see docker/localsettings.py).:
MSSQL_SERVER
MSSQL_USERNAME
MSSQL_PASSWORD
MSSQL_DATABASE
- must run the import on a server that is allowed by the firewall on the SQL Server (e.g. testing server, production server, via VPN) for the 2014-2021 period
- must have a folder with xlsx files for the 2009-2014 period
- must have a json file for period for the 2004-2009 period
-
Run migrations
python manage.py migrate
-
Load fixtures
python manage.py load_fixtures initial
-
Run import script. This will import data for all periods (
2004-2009
,2009-2014
,2014-2021
).python manage.py import --directory=./2009-2014 --json-path=./allocation_2004-2009.json --noinput
-
Import news
python manage.py import_news
-
Rebuild indexes
python manage.py rebuild_index --noinput
A temporary DB can be used to update the DB for a period without downtime. See also import.sh for an example usage.
-
Copy existing DB to a temporary location
cp /var/local/db/eeag.sqlite3 /tmp/eeag.sqlite3
-
Run the import script for the specific period that needs updating (arguments specific to other periods can be omitted):
# for 2004-2009 env DJANGO_DB_PATH=/tmp/eeag.sqlite3 python manage.py import --json-path=./allocation_2004-2009.json --period=2004-2009 # for 2009-2014 env DJANGO_DB_PATH=/tmp/eeag.sqlite3 python manage.py import --directory=./2009-2014 --period=2009-2014 # for 2014-2021 env DJANGO_DB_PATH=/tmp/eeag.sqlite3 python manage.py import --period=2014-2021
-
Move the DB back from the tmp location:
mv /tmp/eeag.sqlite3 /var/local/db/eeag.sqlite3
-
Rebuild indexes. This cannot be done in a tmp location at this time, so searches will be unavailable while this runs:
python manage.py rebuild_index --noinput
-
(Optional) Clear caches:
rm -rf /var/tmp/django_cache