From 54151bb54827b1fb7082fe6a217dfa2b2540c625 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 21 Apr 2020 20:03:12 +0000 Subject: [PATCH] db tools: Rename do-destroy-*database. The new tools now have more concise, more parallel names: - rebuild-dev-database - rebuild-test-database The actual implementations are still pretty different: rebuild-dev-database: mostly delegates to 5 management scripts rebuild-test-database: is a very thin wrapper for generate-fixtures We'll try to clean that up a bit soon. --- docs/development/setup-advanced.md | 4 ++-- docs/development/using.md | 2 +- docs/overview/architecture-overview.md | 2 +- docs/subsystems/schema-migrations.md | 15 +++++++++------ tools/lib/provision_inner.py | 4 ++-- ...troy-rebuild-database => rebuild-dev-database} | 0 ...ebuild-test-database => rebuild-test-database} | 0 7 files changed, 15 insertions(+), 12 deletions(-) rename tools/{do-destroy-rebuild-database => rebuild-dev-database} (100%) rename tools/{do-destroy-rebuild-test-database => rebuild-test-database} (100%) diff --git a/docs/development/setup-advanced.md b/docs/development/setup-advanced.md index be7f62e271..1a60acb245 100644 --- a/docs/development/setup-advanced.md +++ b/docs/development/setup-advanced.md @@ -242,9 +242,9 @@ else fi ./scripts/setup/configure-rabbitmq ./tools/setup/postgres-init-dev-db -./tools/do-destroy-rebuild-database +./tools/rebuild-dev-database ./tools/setup/postgres-init-test-db -./tools/do-destroy-rebuild-test-database +./tools/rebuild-test-database ./manage.py compilemessages ``` diff --git a/docs/development/using.md b/docs/development/using.md index f05fffb5f2..41871ddfb2 100644 --- a/docs/development/using.md +++ b/docs/development/using.md @@ -32,7 +32,7 @@ the development environment][authentication-dev-server]. database with different test data, are documented in-app at `https://localhost:9991/devtools`. * If you want to restore your development environment's database to a - pristine state, you can use `./tools/do-destroy-rebuild-database`. + pristine state, you can use `./tools/rebuild-dev-database`. ## Server diff --git a/docs/overview/architecture-overview.md b/docs/overview/architecture-overview.md index b4fdcfaac6..64e52533c1 100644 --- a/docs/overview/architecture-overview.md +++ b/docs/overview/architecture-overview.md @@ -246,7 +246,7 @@ extension is handled by `tools/postgres-init-dev-db` (invoked by `tools/provision`). That file also manages setting up the development postgresql user. -`tools/provision` also invokes `tools/do-destroy-rebuild-database` +`tools/provision` also invokes `tools/rebuild-dev-database` to create the actual database with its schema. ### Thumbor and thumbnailing diff --git a/docs/subsystems/schema-migrations.md b/docs/subsystems/schema-migrations.md index aab5f83caf..91c13a63a1 100644 --- a/docs/subsystems/schema-migrations.md +++ b/docs/subsystems/schema-migrations.md @@ -149,9 +149,12 @@ If you follow the processes described above, `tools/provision` and migrations and run migrations on (`./manage.py migrate`) or rebuild the relevant database automatically as appropriate. -Developing migrations can result in manual fiddling that leads to a -broken database state, however. For those situations, we have -`tools/do-destroy-rebuild-test-database` and -`tools/do-destroy-rebuild-database` available to rebuild the databases -used for `test-backend` and [manual testing](../development/using.md), -respectively. +While developing migrations, you may accidentally corrupt +your databases while debugging your new code. +You can always rebuild these databases from scratch. + +Use `tools/rebuild-test-database` to rebuild the database +used for `test-backend` and other automated tests. + +Use `tools/rebuild-dev-database` to rebuild the database +used in [manual testing](../development/using.md). diff --git a/tools/lib/provision_inner.py b/tools/lib/provision_inner.py index 06e19e7483..c11fa816e1 100755 --- a/tools/lib/provision_inner.py +++ b/tools/lib/provision_inner.py @@ -213,7 +213,7 @@ def main(options: argparse.Namespace) -> int: dev_template_db_status = DEV_DATABASE.template_status() if options.is_force or dev_template_db_status == 'needs_rebuild': run(["tools/setup/postgres-init-dev-db"]) - run(["tools/do-destroy-rebuild-database"]) + run(["tools/rebuild-dev-database"]) elif dev_template_db_status == 'run_migrations': DEV_DATABASE.run_db_migrations() elif dev_template_db_status == 'current': @@ -222,7 +222,7 @@ def main(options: argparse.Namespace) -> int: test_template_db_status = TEST_DATABASE.template_status() if options.is_force or test_template_db_status == 'needs_rebuild': run(["tools/setup/postgres-init-test-db"]) - run(["tools/do-destroy-rebuild-test-database"]) + run(["tools/rebuild-test-database"]) elif test_template_db_status == 'run_migrations': TEST_DATABASE.run_db_migrations() elif test_template_db_status == 'current': diff --git a/tools/do-destroy-rebuild-database b/tools/rebuild-dev-database similarity index 100% rename from tools/do-destroy-rebuild-database rename to tools/rebuild-dev-database diff --git a/tools/do-destroy-rebuild-test-database b/tools/rebuild-test-database similarity index 100% rename from tools/do-destroy-rebuild-test-database rename to tools/rebuild-test-database