Pie Logo
Quiz: Seeding and Migrations
by Tomas Trescak

QuizTest your understanding of the section content.

ContentDetailed description of the section content.

Full Stack Development
Introduction
Generative AI
🍰 Player
💼 Editor
Setup
React Fundamentals
Next.js
Advanced React
Databases
Fetching Data
SQL vs No-SQL Databases
Prisma and ORM
Seeding and Migrations
Exercise: Seeding and Migrations
Quiz: Seeding and Migrations
Search and Pagination
Server Actions
Client-Side Mutations
Validations and Error Handling
Assignment 2.2: Blog - Admin
React Hooks
Authentication and Authorisation
APIs
CI/CD and DevOps
Testing React
Advanced Topics
    Pie Logo
    Quiz: Seeding and Migrations
    by Tomas Trescak

    QuizTest your understanding of the section content.

    ContentDetailed description of the section content.

    Full Stack Development
    Introduction
    Generative AI
    🍰 Player
    💼 Editor
    Setup
    React Fundamentals
    Next.js
    Advanced React
    Databases
    Fetching Data
    SQL vs No-SQL Databases
    Prisma and ORM
    Seeding and Migrations
    Exercise: Seeding and Migrations
    Quiz: Seeding and Migrations
    Search and Pagination
    Server Actions
    Client-Side Mutations
    Validations and Error Handling
    Assignment 2.2: Blog - Admin
    React Hooks
    Authentication and Authorisation
    APIs
    CI/CD and DevOps
    Testing React
    Advanced Topics

    New Quiz
    by Tomas Trescak· Seeding and Migrations

    QUESTION 1

    Your blog app launches with no posts, and users leave frustrated. You decide to seed data using the seed.ts script from the lecture. What would happen if you ran this code without modifying it?

    const prisma = new PrismaClient();
    
    async function main() {
      await prisma.post.deleteMany();
      await prisma.post.createMany({
        data: [
          { title: "Welcome", content: "Blog launch!", createdAt: new Date("2025-01-01"), tags: ["intro"] },
          { title: "AI Future", content: "Tech is here.", createdAt: new Date("2025-02-15"), tags: ["tech"] },
        ],
      });
    }
    


    QUESTION 2

    You’re working on the blog app with a team. You add a tags field to the Post model in schema.prisma. Which approach should you take to update the database safely, and why?


    QUESTION 3

    In the blog app, a user wants to filter posts by the tag "travel" using this query after seeding:

    const posts = await prisma.post.findMany({ where: { tags: { has: "travel" } } });
    

    Based on the advanced seeding example below, what would happen?

    await prisma.post.createMany({
      data: [
        { title: "Welcome", content: "Blog launch!", createdAt: new Date("2025-01-01"), tags: ["intro", "welcome"] },
        { title: "AI Future", content: "Tech is here.", createdAt: new Date("2025-02-15"), tags: ["tech", "innovation"] },
        { title: "Mountain Trip", content: "Nature calls.", createdAt: new Date("2025-03-01"), tags: ["travel", "nature"] },
      ],
    });
    


    QUESTION 4

    Your blog app is live, and you accidentally run npx prisma db push after removing the content field from schema.prisma. What’s the impact?

    This content is only available to registered users.
    Please register at the the home page.

    New Quiz
    by Tomas Trescak· Seeding and Migrations

    QUESTION 1

    Your blog app launches with no posts, and users leave frustrated. You decide to seed data using the seed.ts script from the lecture. What would happen if you ran this code without modifying it?

    const prisma = new PrismaClient();
    
    async function main() {
      await prisma.post.deleteMany();
      await prisma.post.createMany({
        data: [
          { title: "Welcome", content: "Blog launch!", createdAt: new Date("2025-01-01"), tags: ["intro"] },
          { title: "AI Future", content: "Tech is here.", createdAt: new Date("2025-02-15"), tags: ["tech"] },
        ],
      });
    }
    


    QUESTION 2

    You’re working on the blog app with a team. You add a tags field to the Post model in schema.prisma. Which approach should you take to update the database safely, and why?


    QUESTION 3

    In the blog app, a user wants to filter posts by the tag "travel" using this query after seeding:

    const posts = await prisma.post.findMany({ where: { tags: { has: "travel" } } });
    

    Based on the advanced seeding example below, what would happen?

    await prisma.post.createMany({
      data: [
        { title: "Welcome", content: "Blog launch!", createdAt: new Date("2025-01-01"), tags: ["intro", "welcome"] },
        { title: "AI Future", content: "Tech is here.", createdAt: new Date("2025-02-15"), tags: ["tech", "innovation"] },
        { title: "Mountain Trip", content: "Nature calls.", createdAt: new Date("2025-03-01"), tags: ["travel", "nature"] },
      ],
    });
    


    QUESTION 4

    Your blog app is live, and you accidentally run npx prisma db push after removing the content field from schema.prisma. What’s the impact?

    This content is only available to registered users.
    Please register at the the home page.

    Pie Logo
    Quiz: Seeding and Migrations
    by Tomas Trescak
    Pie Logo
    Quiz: Seeding and Migrations
    by Tomas Trescak
    Full Stack Development
    Introduction
    Generative AI
    🍰 Player
    💼 Editor
    Setup
    React Fundamentals
    Next.js
    Advanced React
    Databases
    Fetching Data
    SQL vs No-SQL Databases
    Prisma and ORM
    Seeding and Migrations
    Exercise: Seeding and Migrations
    Quiz: Seeding and Migrations
    Search and Pagination
    Server Actions
    Client-Side Mutations
    Validations and Error Handling
    Assignment 2.2: Blog - Admin
    React Hooks
    Authentication and Authorisation
    APIs
    CI/CD and DevOps
    Testing React
    Advanced Topics
    Full Stack Development
    Introduction
    Generative AI
    🍰 Player
    💼 Editor
    Setup
    React Fundamentals
    Next.js
    Advanced React
    Databases
    Fetching Data
    SQL vs No-SQL Databases
    Prisma and ORM
    Seeding and Migrations
    Exercise: Seeding and Migrations
    Quiz: Seeding and Migrations
    Search and Pagination
    Server Actions
    Client-Side Mutations
    Validations and Error Handling
    Assignment 2.2: Blog - Admin
    React Hooks
    Authentication and Authorisation
    APIs
    CI/CD and DevOps
    Testing React
    Advanced Topics