updated documentation, disallow clean and import scripts in production

This commit is contained in:
David Kennedy 2024-06-01 19:54:55 -04:00
parent 9f973938a3
commit 736189e22c
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
3 changed files with 21 additions and 4 deletions

View file

@ -11,6 +11,11 @@ Simple scripts are provided as detailed below.
To export from the source environment, run the following command from src directory:
manage.py export_tables
On a sandbox, connect to the sandbox (getgov-stable in ex below) and run the command:
cf ssh getgov-stable
/tmp/lifecycle/shell
./manage.py export_tables
This exports a file, exported_tables.zip, to the tmp directory
For reference, the zip file will contain the following tables in csv form:
@ -27,12 +32,12 @@ For reference, the zip file will contain the following tables in csv form:
* HostIP
After exporting the file from the target environment, scp the exported_tables.zip
file from the target environment to local.
file from the target environment to local. Run the below commands from local.
Get passcode by running:
cf ssh-code
scp file from app (app is getgov-stable in example below) to local cwd:
scp file from app (app is getgov-stable in example below) to local tmp:
scp -P 2222 -o User=cf:$(cf curl /v3/apps/$(cf app getgov-stable --guid)/processes | jq -r '.resources[] | select(.type=="web") | .guid')/0 ssh.fr.cloud.gov:app/tmp/exported_tables.zip .
when prompted, supply the passcode retrieved in the 'cf ssh-code' command

View file

@ -1,4 +1,5 @@
import logging
from django.conf import settings
from django.core.management import BaseCommand
from django.apps import apps
from django.db import transaction
@ -10,9 +11,14 @@ class Command(BaseCommand):
def handle(self, **options):
"""Delete all rows from a list of tables"""
if settings.IS_PRODUCTION:
logger.error("clean_tables cannot be run in production")
return
table_names = [
"DomainInformation", "DomainRequest", "Domain", "User", "Contact",
"Website", "DraftDomain", "HostIp", "Host", "PublicContact"
"DomainInformation", "DomainRequest", "PublicContact", "Domain", "User",
"Contact", "Website", "DraftDomain", "HostIp", "Host"
]
for table_name in table_names:

View file

@ -3,6 +3,7 @@ import os
import pyzipper
import tablib
from django.apps import apps
from django.conf import settings
from django.db import transaction
from django.core.management import BaseCommand
import registrar.admin
@ -14,6 +15,11 @@ class Command(BaseCommand):
def handle(self, **options):
"""Extracts CSV files from a zip archive and imports them into the respective tables"""
if settings.IS_PRODUCTION:
logger.error("import_tables cannot be run in production")
return
table_names = [
"User", "Contact", "Domain", "Host", "HostIp", "DraftDomain", "Website",
"DomainRequest", "DomainInformation", "UserDomainRole", "PublicContact"