Skip to content

feat(aurora-dsql-mcp-server): use native ALTER TABLE DROP COLUMN for DSQL - #4556

Closed
mripley wants to merge 1 commit into
awslabs:mainfrom
mripley:enable-drop-column-support
Closed

mripley wants to merge 1 commit into
awslabs:mainfrom
mripley:enable-drop-column-support

Conversation

@mripley

@mripley mripley commented Aug 28, 2026

Copy link
Copy Markdown

Fixes

Summary

Mirrors awslabs/agent-plugins#264, the canonical home for DSQL agent steering. That PR was authored and reviewed first; this one carries the settled text.

Aurora DSQL shipped ALTER TABLE ... DROP COLUMN on 2026-08-03, but this repo still asserted "DSQL does NOT support direct ... DROP COLUMN" and routed the operation through the destructive Table Recreation Pattern.

DROP COLUMN is synchronous and metadata-only. Unlike VALIDATE CONSTRAINT it has no ALTER TABLE ASYNC form and returns no job_id.

Changes

Both agent-facing surfaces in this package are updated:

  • skills/dsql-skill/ (source of truth) — SKILL.md plus references/development-guide.md, references/ddl-migrations/{overview,column-operations}.md, references/mysql-migrations/{ddl-column-changes,type-mapping}.md.
    The five alias SKILL.md files were regenerated by the sync-dsql-skill-aliases pre-commit hook, not hand-edited — they differ from the source on the name: line only, and the hook is idempotent on a second pass.
  • kiro_power/ — POWER.md plus the flattened steering/ counterparts. Each steering/*.md remains byte-identical to its references/ counterpart.
  • CHANGELOG.md — entry under ## Unreleased.

Substance (identical to the canonical PR): the rule lands in the always-loaded development-guide.md; column-operations.md documents the native statement with the rules that actually bite — PK key columns rejected with 0A000, CASCADE only for out-of-table dependents (a bare drop already sweeps the column's indexes and same-table constraints), CASCADE itself failing 0A000 when the dependency chain reaches a PK key column, IF EXISTS, gradual storage reclamation, and the 255-active / 1,600-lifetime column budget.

The Workflow 6 sentence is now affirmative rather than "DSQL does NOT support direct ...", matching the canonical wording and the project's steering style.

Table recreation is unchanged for ALTER COLUMN TYPE, SET NOT NULL, DROP CONSTRAINT, and MODIFY PRIMARY KEY.

User experience

Before — asked to drop an obsolete column, the agent produced a destructive multi-step migration: create a replacement table, INSERT ... SELECT every row (batched under 3,000), verify counts, DROP TABLE, RENAME, then rebuild indexes. On an 80k-row table that is minutes of work, a write outage, and an irreversible DROP TABLE.

After — the agent emits ALTER TABLE orders DROP COLUMN legacy_promo_code, confirms the table and column with the user first, and adds CASCADE only when a dependency actually requires it.

Measured against the eval suite in awslabs/agent-plugins (regex-graded, no cluster needed): 0/2 on the pre-change skill, 2/2 after.

Checklist

  • I have reviewed the contributing guidelines
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented

Is this a breaking change? (Y/N) N

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Testing notes

Documentation-only; the MCP server implementation is untouched. Verified:

  • skills/dsql-skill/ passes skill structure/frontmatter validation; SKILL.md 343 lines and POWER.md 259, both under the 500-line cap.
  • All five reference↔steering pairs byte-identical (diff per pair — note a recursive diff -r is not a valid check here, since subdirectory files are flattened into steering/ filenames).
  • All five alias SKILL.md files differ from dsql-skill/SKILL.md on exactly the name: line.
  • No trailing whitespace, CRLF, or missing EOF newline in any changed file.

Pre-existing issue noted but not fixed

The steering/ tree was flattened without rewriting intra-document relative links, so links like ../ddl-migrations/column-operations.md are already dead there (23 instances across the files this PR touches). This PR preserves the byte-identical mirror rather than diverging the two trees, so it neither fixes nor worsens the aggregate count. Happy to follow up with a dedicated link-rewrite pass if you'd prefer that separately.

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

…DSQL

Mirrors awslabs/agent-plugins, the canonical home for DSQL agent steering.
Aurora DSQL shipped ALTER TABLE ... DROP COLUMN on 2026-08-03, but this repo
still asserted "DSQL does NOT support direct ... DROP COLUMN" and routed the
operation through the destructive Table Recreation Pattern.

DROP COLUMN is synchronous and metadata-only. Unlike VALIDATE CONSTRAINT it
has no ALTER TABLE ASYNC form and returns no job_id.

Both surfaces updated:
- skills/dsql-skill/ (SKILL.md + references/) -- source of truth. The five
  alias SKILL.md files were regenerated by the sync-dsql-skill-aliases hook,
  not hand-edited.
- kiro_power/ (POWER.md + steering/) -- translated to the flat steering
  layout. steering/*.md stays byte-identical to its references/ counterpart.

Content changes match agent-plugins: the rule lands in the always-loaded
development-guide, column-operations documents the native statement with the
PK/CASCADE/column-budget rules, and the workflow leads with the native path.
The "DSQL does NOT support direct ..." sentence is now affirmative, matching
the canonical wording and house style.

Table recreation is unchanged for ALTER COLUMN TYPE, SET NOT NULL,
DROP CONSTRAINT, and MODIFY PRIMARY KEY.
@anwesham-lab

anwesham-lab commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

closing in favor of skill deprecation

the agent plugin will be the sole source of truth

@github-project-automation github-project-automation Bot moved this from To triage to Done in awslabs/mcp Project Aug 31, 2026
praba2210 pushed a commit to awslabs/aurora-dsql-orms that referenced this pull request Oct 7, 2026
…MN (#600)

## Summary

`test_aerich_add_column_migration` skipped its downgrade half behind
this comment:

```python
# Note: Downgrade not tested here because DSQL doesn't support ALTER TABLE DROP COLUMN.
# See other tests for downgrade testing.
```

Aurora DSQL has supported `ALTER TABLE ... DROP COLUMN` since
[2026-08-03](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/release-notes.html),
so the note is stale — and it was suppressing real coverage: the aerich
downgrade path for a column-adding migration was going untested.

## Changes

- Capture the `Command` returned by `migrate_to()` so `downgrade()` can
be called on it. The original code discarded the return value, so there
was no handle to downgrade with.
- Downgrade and assert the added column is gone while its sibling
survives.

This follows the shape already used by
`test_aerich_add_model_and_downgrade_last` and
`test_aerich_multi_model_migration` — same `command = await
migrate_to(...)` capture, same `downgrade(version=-1, delete=False)`
call, same connection re-fetch and assertion style. Column-level
assertions use the existing `get_table_columns()` helper (as this test
already does) rather than the `table_exists` the 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_field` calls `ddl.drop_column`, and
`PostgresDDL` inherits the base template `ALTER TABLE "{table_name}"
DROP COLUMN "{column_name}"` — no `CASCADE`, no MySQL-style quoting.
`aurora_dsql_tortoise/aerich/patch.py` does 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.py` validates `CLUSTER_ENDPOINT` at import
time), so it runs in CI via the `dsql-cluster-create` workflow rather
than locally. Verified offline:

- `pytest --collect-only tests/integration/test_aerich.py` → **26 tests
collected**, including `test_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 COLUMN` rollout:

- Agent steering (canonical):
[awslabs/agent-plugins#264](awslabs/agent-plugins#264)
- Agent steering (mirror):
[awslabs/mcp#4556](awslabs/mcp#4556)

The adapters themselves already emit native `DROP COLUMN` as of #588 —
this was the last spot in the repo still gated on the old limitation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants