Skip to main content
← Back to list
01Issue
FeatureClosedSwamp Club
AssigneesNone

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:

  1. Tear down and recreate — destroy working dev infrastructure, recreate with new names. Downtime, risk, and wasted effort.
  2. CEL conditionals everywhereinputs.env == "dev" ? "web-vpc" : inputs.env + "-web-vpc" in every model reference. Ugly, error-prone, doesn't scale.
  3. 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:

  1. Update the data instance name from old-name to new-name
  2. Preserve all versions, ownership, and tags
  3. Update the latest symlink
  4. Make data.latest("model", "new-name") resolve correctly

Alternatives Considered

  • Data aliasing — allow a data instance to have multiple names (alias web-vpcdev-web-vpc). More flexible but more complex.
  • Bulk rename with patternswamp data rename --model web-vpc --pattern '{name}' --to 'dev-{name}' for batch operations during refactoring.
  • Copy instead of moveswamp data copy that duplicates data under a new name. Safer but doubles storage.
02Bog Flow
OPENTRIAGEDIN PROGRESSCLOSED

Closed

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.