Exercise 2: Renaming a Column Without Losing Data — Possible Solution ======================================================================= 1. Create a post (for example in a script): await prisma.post.create({ data: { title: "Hello", slug: "hello", content: "My first post" }, }); 2. In schema.prisma, rename the field: content String? -> body String? 3. Create the migration without applying it: $ npx prisma migrate dev --create-only --name rename-content-to-body Open the new migration.sql. Prisma has treated the rename as "remove content, add body" — on SQLite this often appears as rebuilding the whole table without the old column. Applied as it is, the post's text would be lost. 4. Replace the generated contents with: ALTER TABLE "Post" RENAME COLUMN "content" TO "body"; 5. Apply it and regenerate: $ npx prisma migrate dev $ npx prisma generate 6. Prove the data survived: const post = await prisma.post.findUnique({ where: { slug: "hello" } }); console.log(post?.body); // "My first post" (Alternative with no migration at all: name the field body and add @map("content") — the code uses the new name, the column keeps the old one.) WHY THIS WORKS AS AN ANSWER ------------------------------ It shows why Prisma's automatic migration would lose the data, fixes it by editing the SQL before it runs, and checks the result rather than assuming it worked.