Add data rename/move command for non-destructive refactoring
Opened by swampadmin · 5/25/2025
Problem
Data instance names are permanent once created. There is no swamp data rename or swamp data move command. This makes any refactoring that changes resource naming conventions destructive.
Real scenario: Built single-environment infrastructure with instance names like web-vpc, web-lb, web-firewall. Now need to refactor to multi-environment (dev-web-vpc, staging-web-vpc). The existing dev data is stored under web-vpc — there's no way to rename it to dev-web-vpc so that parameterized models can find it.
The only options today are all bad:
- Tear down and recreate — destroy working dev infrastructure, recreate with new names. Downtime, risk, and wasted effort.
- CEL conditionals everywhere —
inputs.env == "dev" ? "web-vpc" : inputs.env + "-web-vpc"in every model reference. Ugly, error-prone, doesn't scale. - Accept orphaned data — old data stays around with no references, new data duplicates the resources. Confusing and wasteful.
Why this matters
Swamp encourages starting simple and iterating. But the data model punishes that — naming decisions made at day 1 are irreversible. The path from "I built a thing" to "now I need two of them" should be a straightforward refactoring, not a destructive rebuild.
Infrastructure naming conventions always evolve. Teams add environments, rename resources for consistency, reorganize by region or team. A data layer that can't accommodate renaming forces users to either over-engineer naming from the start (defeating "start simple") or pay a heavy refactoring tax later.
Proposed Solution
Add a swamp data rename (or swamp data move) command:
swamp data rename <model> <old-name> <new-name>This would:
- Update the data instance name from
old-nametonew-name - Preserve all versions, ownership, and tags
- Update the
latestsymlink - Make
data.latest("model", "new-name")resolve correctly
Alternatives Considered
- Data aliasing — allow a data instance to have multiple names (alias
web-vpc→dev-web-vpc). More flexible but more complex. - Bulk rename with pattern —
swamp data rename --model web-vpc --pattern '{name}' --to 'dev-{name}'for batch operations during refactoring. - Copy instead of move —
swamp data copythat duplicates data under a new name. Safer but doubles storage.
Closed
No activity in this phase yet.
Sign in to post a ripple.