From f60f2bff050bfd60aff3448db4d6b09e471bc4cc Mon Sep 17 00:00:00 2001 From: rachidatecs Date: Wed, 17 May 2023 18:41:52 -0400 Subject: [PATCH 1/3] Document local migrations, mention --wait for cf migrations --- docs/developer/database-access.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/developer/database-access.md b/docs/developer/database-access.md index 8fc5d4617..8c0fc612e 100644 --- a/docs/developer/database-access.md +++ b/docs/developer/database-access.md @@ -12,19 +12,32 @@ to get a `psql` shell on the sandbox environment's database. ## Running Migrations +### On Local + +```shell +docker-compose exec app bash +./manage.py makemigrations +``` + +The docker compose down then up to run the new migrations. + +### On Cloud.gov + When new code changes the database schema, we need to apply Django's migrations. We can run these using CloudFoundry's tasks to run the `manage.py migrate` command in the correct environment. For any developer environment, developers can manually run the task with ```shell -cf run-task getgov-ENVIRONMENT --command 'python manage.py migrate' --name migrate +cf run-task getgov-ENVIRONMENT --wait --command 'python manage.py migrate' --name migrate ``` +(The optional 'wait' argument will wait until the environment is stable) + Optionally, load data from fixtures as well ```shell -cf run-task getgov-ENVIRONMENT --command 'python manage.py load' --name loaddata +cf run-task getgov-ENVIRONMENT --wait --command 'python manage.py load' --name loaddata ``` For the `stable` environment, developers don't have credentials so we need to From c086d4c7b75cc1e97f92c817e5be68debcf71489 Mon Sep 17 00:00:00 2001 From: rachidatecs <107004823+rachidatecs@users.noreply.github.com> Date: Wed, 17 May 2023 20:45:21 -0400 Subject: [PATCH 2/3] Update docs/developer/database-access.md Co-authored-by: Alysia Broddrick <109625347+abroddrick@users.noreply.github.com> --- docs/developer/database-access.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developer/database-access.md b/docs/developer/database-access.md index 8c0fc612e..2fc05013b 100644 --- a/docs/developer/database-access.md +++ b/docs/developer/database-access.md @@ -19,7 +19,7 @@ docker-compose exec app bash ./manage.py makemigrations ``` -The docker compose down then up to run the new migrations. +Then perform docker-compose down & docker-compose up to run with the new migrations. ### On Cloud.gov From 4f96fd65a7d995be281c478e10627f9645b79672 Mon Sep 17 00:00:00 2001 From: rachidatecs Date: Wed, 17 May 2023 20:49:58 -0400 Subject: [PATCH 3/3] Add context for migrations documentation --- docs/developer/database-access.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/developer/database-access.md b/docs/developer/database-access.md index 8c0fc612e..7c7d28881 100644 --- a/docs/developer/database-access.md +++ b/docs/developer/database-access.md @@ -12,6 +12,9 @@ to get a `psql` shell on the sandbox environment's database. ## Running Migrations +When new code changes the database schema (ie, you change a model or pull some +code that has), we need to apply Django's migrations. + ### On Local ```shell @@ -23,7 +26,6 @@ The docker compose down then up to run the new migrations. ### On Cloud.gov -When new code changes the database schema, we need to apply Django's migrations. We can run these using CloudFoundry's tasks to run the `manage.py migrate` command in the correct environment. For any developer environment, developers can manually run the task with