Skip to content

AAI-119 set up migrations for aai-backend database#35

Merged
marius-mather merged 7 commits into
mainfrom
db-migrations
Jul 2, 2025
Merged

AAI-119 set up migrations for aai-backend database#35
marius-mather merged 7 commits into
mainfrom
db-migrations

Conversation

@marius-mather

@marius-mather marius-mather commented Jul 1, 2025

Copy link
Copy Markdown
Collaborator

Description

AAI-119: set up ways to generate migrations (using a local postgres instance) and ensure we can run them against the deployed service.

Changes

  • Create a generate_migrations.py script to generate migrations against a postgres instance
  • Update CDK deployment to allow command execution for migrations
  • Generate initial migrations

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have added unit / integration tests that prove my fix is effective or that my feature works
  • I have run all tests locally and they pass
  • I have updated the documentation (if applicable)

How to Test Manually (if necessary)

Run uv run python generate_migrations.py --check to check that alembic is happy with the state of the migrations.

@amandazhuyilan

Copy link
Copy Markdown
Contributor

Ran uv run python generate_migrations.py --check locally with this branch and seems that everyone has to be happy:

🚀 Starting temporary Postgres container...
> docker run --rm -d --name temp_alembic_db -e POSTGRES_USER=testuser -e POSTGRES_PASSWORD=testpass -p 5433:5432 postgres:17
cb158ede614f9d26c93c0e56c1d456e8249dfc8a3c7d09464a4cdbc18abe9d52
⏳ Waiting for database to be ready...
🧱 Applying existing Alembic migrations...
> alembic upgrade head
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 101f45395233, add_group_membership
🔍 Running 'alembic check'...
> alembic check
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
No new upgrade operations detected.
🧹 Cleaning up: stopping container...
temp_alembic_db

Had to restart my docker on mac first ;)

@amandazhuyilan amandazhuyilan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me - thanks for making the change

@marius-mather marius-mather merged commit 99a3dc7 into main Jul 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants