-
Notifications
You must be signed in to change notification settings - Fork 6
Populating the database
Dylan Hillerbrand edited this page Apr 3, 2024
·
1 revision
Populate a new deployment of the database using these instructions. If you populating a new version of the production site, special care must be taken to ensure that no data is lost in transition between servers, including by limiting edit access by users for a maintenance period.
- Obtain a back-up of the database, probably from one of the nightly automated backups on deployed staging and production servers. If this file is compressed, unpack it.
- Enter the Postgres container:
docker-compose exec postgres bash
. - Access psql:
psql postgres cantusdb
. The first argument is the DB name, second is the username. - If you already have a
cantusdb
database in your Postgres, runDROP DATABASE cantusdb;
. - Create a database named cantusdb:
CREATE DATABASE cantusdb;
- Quit psql, exit the Postgres container, and run
docker-compose exec -T postgres psql -U cantusdb cantusdb < /path/to/cantus_dump.sql
to load the dump into your newly created database. - enter the Django container (
docker-compose exec django bash
), and runpython manage.py migrate
. You should see something like:
Operations to perform:
Apply all migrations: admin, articles, auth, contenttypes, flatpages, main_app, sessions, sites, users
Running migrations:
No migrations to apply.
- In the admin interface, go to "Sites". There should be one site listed. Ensure this site's Domain Name and Display Name are correct
- If this is not configured correctly, the links in password reset emails (for example) will redirect users to the incorrect site
- if the database dump came from the Production site, the Domain Name will be
cantusdatabase.org
. On Staging, the Domain Name should be changed tostaging.cantusdatabase.org
and the Display Name should be set toCantus Database Staging
. In local development, the Domain Name should be set tolocalhost
or127.0.0.1
.
- At this point, everything should be set up. Visit the app in a browser and try navigating to various sources, chants, etc. to ensure that everything has loaded correctly.