docs/1.17/data-model-and-migrations/migrations-asdf.mdx
import Warning from 'components/Markdown/Warning'
export const meta = { title: "Migrations", position: 240 }
If your Prisma server is configured to allow database migrations, you can use SDL to define and migrate your database schema.
Prisma uses temporary directives to perform one-time migration operations. After deploying a service that contain a temporary directive, a temporary directive needs to be manually removed from the type definitions file.
The temporary directive @rename(oldName: String!) is used to rename types and field.
If the @rename directive is not used, Prisma removes the old type and field before creating the new one, resulting in loss of data!
Renaming the Post type to Story
type Story @rename(oldName: "Post") {
content: String
}
The @rename(oldName: "Post") directive needs to be deleted manually after prisma deploy was executed and the renaming was performed.
Renaming the text field to content
type Story {
content: String @rename(oldName: "text")
}
The @rename(oldName: "text") directive needs to be deleted manually after prisma deploy was executed and the renaming was performed.