Expose foreign key data to alter table UI

Include current foreign key metadata in the alter table page data and allow the foreign-key-targets endpoint to be read by actors with alter-table permission for a specific table.

Add API and HTML data tests for the new alter-table foreign key support.
This commit is contained in:
Simon Willison 2026-06-22 12:47:02 -07:00
commit 063b04ad83
4 changed files with 46 additions and 2 deletions

View file

@ -1252,6 +1252,17 @@ async def test_foreign_key_targets_permission_denied(ds_write):
}
@pytest.mark.asyncio
async def test_foreign_key_targets_allowed_for_alter_table(ds_write):
token = write_token(ds_write, permissions=["at"])
response = await ds_write.client.get(
"/data/-/foreign-key-targets?table=docs",
headers=_headers(token),
)
assert response.status_code == 200, response.text
assert response.json()["ok"] is True
@pytest.mark.asyncio
async def test_alter_table_permission_denied(ds_write):
token = write_token(ds_write, permissions=["ir"])