Conversation
test_aerich_add_column_migration skipped its downgrade half behind a comment saying DSQL does not support ALTER TABLE DROP COLUMN. That has been supported since 2026-08-03, so the note was stale and the aerich downgrade path was going untested. Capture the Command returned by migrate_to() so downgrade() can be called on it, then assert the column is gone and its sibling survives -- the same shape as test_aerich_add_model_and_downgrade_last and test_aerich_multi_model_migration. aerich's Migrate._remove_field emits the base PostgresDDL template ALTER TABLE "t" DROP COLUMN "c" as a single-statement DDL, which DSQL accepts; the tortoise adapter does not intercept it.
Integration test results — run against a live clusterRan on a DSQL gamma cluster in
The two assertions cannot pass vacuously: Full integration suite — 204 passed, 8 failed. All 8 failures are in Those 8 are an artifact of testing against a gamma cluster. They derive the endpoint from cluster-id + region, which produces the production hostname form: Note the missing Verified as pre-existing rather than assumed: I checked out unmodified |
Summary
test_aerich_add_column_migrationskipped its downgrade half behind this comment:Aurora DSQL has supported
ALTER TABLE ... DROP COLUMNsince 2026-08-03, so the note is stale — and it was suppressing real coverage: the aerich downgrade path for a column-adding migration was going untested.Changes
Commandreturned bymigrate_to()sodowngrade()can be called on it. The original code discarded the return value, so there was no handle to downgrade with.This follows the shape already used by
test_aerich_add_model_and_downgrade_lastandtest_aerich_multi_model_migration— samecommand = await migrate_to(...)capture, samedowngrade(version=-1, delete=False)call, same connection re-fetch and assertion style. Column-level assertions use the existingget_table_columns()helper (as this test already does) rather than thetable_existsthe model-level siblings use, since this migration adds a column rather than a table. No new helper, fixture, or marker.Why the emitted SQL is safe on DSQL
aerich's
Migrate._remove_fieldcallsddl.drop_column, andPostgresDDLinherits the base templateALTER TABLE "{table_name}" DROP COLUMN "{column_name}"— noCASCADE, no MySQL-style quoting.aurora_dsql_tortoise/aerich/patch.pydoes not intercept drops, so it reaches DSQL as a single-statement DDL, which is what DSQL requires. The column here is an ordinary non-key column, so it avoids the one restriction that remains: dropping a primary key column is still unsupported.Testing
This is an integration test requiring a live DSQL cluster and IAM auth (
tests/integration/conftest.pyvalidatesCLUSTER_ENDPOINTat import time), so it runs in CI via thedsql-cluster-createworkflow rather than locally. Verified offline:pytest --collect-only tests/integration/test_aerich.py→ 26 tests collected, includingtest_aerich_add_column_migration[psycopg]and[asyncpg]. Collection exercises the real import chain, including the DSQL backend registration.ruff check→ all checks passed;ruff format --check→ already formatted.Please run the integration suite on this branch to confirm the downgrade passes against a real cluster.
Related
Part of the DSQL
DROP COLUMNrollout:The adapters themselves already emit native
DROP COLUMNas of #588 — this was the last spot in the repo still gated on the old limitation.