Skip to content

Generate developer database

Rasmus Rudling edited this page Nov 10, 2021 · 12 revisions
  1. Terminal #1 - SSH into the server: ssh [email protected]
  2. Terminal #1 - Run script that creates new developer database: ./dump-database.sh
  3. In terminal #2 - Copy the developer database to your local computer in your current folder: scp [email protected]:/home/ais/ais-database.sql ais-database-with-sensitive-info.sql

Remove sensitive info

Make sensitive database your local database

  1. Move ais-developer-database.sql to the AIS repo and enter its directory, then:**
  2. vagrant up
  3. vagrant ssh
  4. Log into psql as postgres user: psql -U postgres
  5. Drop database: drop database ais_dev;
  6. Quit psql: \q
  7. Create database as user postgres: psql -U postgres < ais-database-with-sensitive-info.sql

Create and run script files for removing sensitive data

# remove_sensitive_info.py
from recruitment.models import *
from fair.models import *
remove_years = ['2016','2017','2018', '2019', '2020', '2021']
for year in remove_years:
    recruitment_periods = RecruitmentPeriod.objects.filter(fair__year = year)
    for period in recruitment_periods:
        applications = RecruitmentApplication.objects.filter(recruitment_period = period)
        for application in applications:
            user = application.user
            application.delete()
            print(year, "    ", period, "    ", user)
            comments = RecruitmentApplicationComment.objects.filter(recruitment_application=application).delete()
            answers = CustomFieldAnswer.objects.filter(user=user).delete()

Run the script file python manage.py shell < remove_sensitive_info.py

Dump the new database without sensitive info

  1. pg_dumpall -U postgres > ais-developer-database.sql

Send ais-developer-database.sql to your developers!

Clone this wiki locally