Skip to content

NAMESPACE MOVE

Renames a namespace by moving its FoundationDB directory from the old path to the new path.

NAMESPACE MOVE <old-namespace> <new-namespace>
ParameterTypeRequiredDescription
old-namespacestringYesDot-separated hierarchical path of the source namespace (e.g. staging.orders).
new-namespacestringYesDot-separated hierarchical path for the destination namespace (e.g. production.orders).

Returns OK on success.

The command moves a namespace from old-namespace to new-namespace within the FoundationDB directory layer. The operation uses an isolated one-off transaction to prevent consistency issues.

Before performing the move, the command checks whether the old namespace is marked for removal. If it is, the operation is rejected.

The __internal__ name is reserved at any level of the hierarchy and cannot be used in either the old or new path.

After moving the directory, a tombstone with a unique token is written under the old namespace name. This marks the old path as “recently moved.”

A cluster-wide event is published to the journal. Every cluster member that consumes this event:

  1. Invalidates its bucket metadata cache entries keyed under the old namespace
  2. Invalidates Bucket plan cache entries keyed under the old namespace
  3. Removes the old namespace from all sessions’ open-namespaces set
  4. Acknowledges the tombstone

The tombstone acts as a barrier: NAMESPACE CREATE on the old name is blocked until every alive cluster member has observed the tombstone. This prevents a member that still caches the old namespace from serving stale data under a newly created namespace with the same name.

Once all alive members have observed, the tombstone is automatically cleaned up on the next barrier check. If any alive member has not yet observed, the barrier check re-publishes the event to nudge lagging members.

Error CodeDescription
NOSUCHNAMESPACEThe source namespace does not exist.
NAMESPACEALREADYEXISTSThe destination namespace already exists.
NAMESPACEBEINGREMOVEDThe source namespace is marked for removal via NAMESPACE REMOVE and has not yet been purged.
ERRThe namespace path contains the reserved __internal__ name.

Move a namespace:

> NAMESPACE CREATE staging.orders
OK
> NAMESPACE MOVE staging.orders production.orders
OK

Non-existent source:

> NAMESPACE MOVE non.existent production.orders
(error) NOSUCHNAMESPACE No such namespace: 'non.existent'

Destination already exists:

> NAMESPACE CREATE staging.orders
OK
> NAMESPACE CREATE production.orders
OK
> NAMESPACE MOVE staging.orders production.orders
(error) NAMESPACEALREADYEXISTS Namespace already exists: production.orders

Namespace being removed:

> NAMESPACE CREATE staging.orders
OK
> NAMESPACE REMOVE staging.orders
OK
> NAMESPACE MOVE staging.orders production.orders
(error) NAMESPACEBEINGREMOVED Namespace 'staging.orders' is being removed

Reserved name:

> NAMESPACE MOVE name.__internal__ production.data
(error) ERR Namespace 'name.__internal__' is reserved for internal use