Skip to content

Drop orphaned per-site agent tables#969

Merged
chubes4 merged 1 commit intomainfrom
fix/cleanup-orphaned-agent-tables
Mar 25, 2026
Merged

Drop orphaned per-site agent tables#969
chubes4 merged 1 commit intomainfrom
fix/cleanup-orphaned-agent-tables

Conversation

@chubes4
Copy link
Member

@chubes4 chubes4 commented Mar 25, 2026

Summary

  • Adds datamachine_drop_orphaned_agent_tables() to clean up per-site agent tables left behind by the network migration
  • Runs during activation, after datamachine_migrate_agents_to_network_scope()
  • Guarded by datamachine_orphaned_agent_tables_dropped site option (idempotent)

Problem

The network migration consolidated agent data into c8c_datamachine_agents (base_prefix) but left orphaned per-site copies:

  • c8c_7_datamachine_agents (events)
  • c8c_11_datamachine_agents (wire)
  • c8c_12_datamachine_agents (studio)
  • Plus corresponding _agent_access and _agent_tokens tables

These are never queried (all 3 repos override to base_prefix) but their existence is confusing — the studio site had a duplicate "roadie" agent (ID 1) in its per-site table while the canonical one is ID 7 in the network table.

Already cleaned up on production

The orphaned tables have been dropped manually on the live server and the flag set. This PR ensures the cleanup runs automatically on future deploys/activations.

The network migration (datamachine_migrate_agents_to_network_scope)
consolidated agent data into base_prefix tables but left the per-site
copies behind. These orphans are never queried (all repos use
base_prefix) and their presence causes confusion about which table
is canonical.

Adds datamachine_drop_orphaned_agent_tables() which runs after the
migration during activation. Guarded by its own site option flag.
@chubes4 chubes4 merged commit fe3cb09 into main Mar 25, 2026
1 check failed
@chubes4 chubes4 deleted the fix/cleanup-orphaned-agent-tables branch March 25, 2026 14:57
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.

1 participant