mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-22 17:21:06 +02:00
updated documentation, disallow clean and import scripts in production
This commit is contained in:
parent
9f973938a3
commit
736189e22c
3 changed files with 21 additions and 4 deletions
|
@ -11,6 +11,11 @@ Simple scripts are provided as detailed below.
|
||||||
To export from the source environment, run the following command from src directory:
|
To export from the source environment, run the following command from src directory:
|
||||||
manage.py export_tables
|
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
|
This exports a file, exported_tables.zip, to the tmp directory
|
||||||
|
|
||||||
For reference, the zip file will contain the following tables in csv form:
|
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
|
* HostIP
|
||||||
|
|
||||||
After exporting the file from the target environment, scp the exported_tables.zip
|
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:
|
Get passcode by running:
|
||||||
cf ssh-code
|
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 .
|
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
|
when prompted, supply the passcode retrieved in the 'cf ssh-code' command
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
from django.conf import settings
|
||||||
from django.core.management import BaseCommand
|
from django.core.management import BaseCommand
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
@ -10,9 +11,14 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
"""Delete all rows from a list of tables"""
|
"""Delete all rows from a list of tables"""
|
||||||
|
|
||||||
|
if settings.IS_PRODUCTION:
|
||||||
|
logger.error("clean_tables cannot be run in production")
|
||||||
|
return
|
||||||
|
|
||||||
table_names = [
|
table_names = [
|
||||||
"DomainInformation", "DomainRequest", "Domain", "User", "Contact",
|
"DomainInformation", "DomainRequest", "PublicContact", "Domain", "User",
|
||||||
"Website", "DraftDomain", "HostIp", "Host", "PublicContact"
|
"Contact", "Website", "DraftDomain", "HostIp", "Host"
|
||||||
]
|
]
|
||||||
|
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
|
|
|
@ -3,6 +3,7 @@ import os
|
||||||
import pyzipper
|
import pyzipper
|
||||||
import tablib
|
import tablib
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
from django.conf import settings
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.core.management import BaseCommand
|
from django.core.management import BaseCommand
|
||||||
import registrar.admin
|
import registrar.admin
|
||||||
|
@ -14,6 +15,11 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
"""Extracts CSV files from a zip archive and imports them into the respective tables"""
|
"""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 = [
|
table_names = [
|
||||||
"User", "Contact", "Domain", "Host", "HostIp", "DraftDomain", "Website",
|
"User", "Contact", "Domain", "Host", "HostIp", "DraftDomain", "Website",
|
||||||
"DomainRequest", "DomainInformation", "UserDomainRole", "PublicContact"
|
"DomainRequest", "DomainInformation", "UserDomainRole", "PublicContact"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue