Rename a field without orphaning existing data
Use renameTo and a safe default while documents migrate lazily to a new field name.
This generated recipe is review-ready source material. Use it from the runtime where it appears in the sidebar and search results.
Use renameTo and a safe default while documents migrate lazily to a new field name.
Use this when
- rename a field safely
- change a field name without losing data
- migrate an existing schema
- keep old documents working after a rename
Dyrected concepts
renameTo, defaultValue, schema evolution
Additional packages: No additional packages.
Decisions and cautions
Use this recipe only when its runtime matches the project you are documenting or building. Cloud recipes must stay inside the managed content backend boundary. Self-hosted recipes may use the server runtime, database, hooks, and infrastructure you control.
Complete recipe
This is the canonical source compiled and behavior-tested by @dyrected/knowledge.
import { defineCollection, defineTextField } from "@dyrected/core";
export const Customers = defineCollection({
slug: "customers",
fields: [
defineTextField({
name: "fullName",
label: "Full name",
renameTo: "name",
defaultValue: "",
required: true,
}),
],
});