Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ check: format-check lint test
# Docker starts the image for the DB but it's not quite
# fully ready, so add a 5 second sleep so upgrade doesn't
# fail because the DB hasn't started yet.
init-db: start-db sleep-5 db-upgrade
init-db: start-db sleep-5 db-migrate

start-db:
docker-compose up --detach main-db
Expand All @@ -131,13 +131,13 @@ db-recreate: clean-volumes init-db
alembic_config := ./src/db/migrations/alembic.ini
alembic_cmd := $(PY_RUN_CMD) alembic --config $(alembic_config)

db-upgrade: ## Apply pending migrations to db
db-migrate: ## Apply pending migrations to db
$(PY_RUN_CMD) db-migrate

db-downgrade: ## Rollback last migration in db
db-migrate-down: ## Rollback last migration in db
$(PY_RUN_CMD) db-migrate-down

db-downgrade-all: ## Rollback all migrations
db-migrate-down-all: ## Rollback all migrations
$(PY_RUN_CMD) db-migrate-down-all

check-migrate-msg:
Expand Down
23 changes: 12 additions & 11 deletions docs/app/database/database-management.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Database Management

- [Basic operations](#basic-operations)
- [Initialize](#initialize)
- [Start](#start)
- [Destroy and reinitialize](#destroy-and-reinitialize)
- [Running migrations](#running-migrations)
- [Creating new migrations](#creating-new-migrations)
- [Multi-head situations](#multi-head-situations)
- [Database Management](#database-management)
- [Basic operations](#basic-operations)
- [Initialize](#initialize)
- [Start](#start)
- [Destroy and reinitialize](#destroy-and-reinitialize)
- [Running migrations](#running-migrations)
- [Creating new migrations](#creating-new-migrations)
- [Multi-head situations](#multi-head-situations)

## Basic operations
### Initialize
Expand Down Expand Up @@ -43,9 +44,9 @@ against your db so it has all the required tables. `make init` does this, but if
needing to work with the migrations directly, some common commands:

```sh
make db-upgrade # Apply pending migrations to db
make db-downgrade # Rollback last migration to db
make db-downgrade-all # Rollback all migrations
make db-migrate # Apply pending migrations to db
make db-migrate-down # Rollback last migration to db
make db-migrate-down-all # Rollback all migrations
```

## Creating new migrations
Expand All @@ -54,7 +55,7 @@ If you've changed a python object model, auto-generate a migration file for the

```sh
$ make db-migrate-create MIGRATE_MSG="<brief description of change>"
$ make db-upgrade
$ make db-migrate
```

<details>
Expand Down