Pie Logo
Exercise: Seeding and Migrations
by Tomas Trescak

PresentationInteractive, narrated presentation of the section content.

ContentDetailed description of the section content.

This time, we have no way of checking whether you have completed your solution or not so please try to complete this assessment and make sure you understand both processes:

Instructions

  1. Create an empty next.js project npxcreate-next-app@latest prisma-play
  2. Initialise Prisma
    1.  pnpm i prisma @prisma/client
    2. pnpm prisma init
  3. Change the provider to sqlite and set the DATABASE_URL in your .env file to file:./dev.db
  4. Use the following Schema
  5. model Post {
      id        Int      @id @default(autoincrement())
      title     String
      content   String
      createdAt DateTime @default(now())
    }
  6. Run the migration pnpm prisma migrate dev --name intial
  7. Seed the database with some data
  8. Modify the schema as follows:
  9. model Post {
      id        Int      @id @default(autoincrement())
      title     String
      content   String
      createdAt DateTime @default(now())
      tags      String
    }
  10. Run the migration 
  11. Could you migrate? If not, can you fix the schema and migrate again!
  12. Re-seed the data with new structure
  13. Check out changes with prisma studio
  14. Roll back the migration

 

Discuss with OthersAsk questions, share your thoughts, and discuss with other learners.

Loading discussion ...
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
    Exercise: Seeding and Migrations
    by Tomas Trescak

    PresentationInteractive, narrated presentation of the section content.

    ContentDetailed description of the section content.

    This time, we have no way of checking whether you have completed your solution or not so please try to complete this assessment and make sure you understand both processes:

    Instructions

    1. Create an empty next.js project npxcreate-next-app@latest prisma-play
    2. Initialise Prisma
      1.  pnpm i prisma @prisma/client
      2. pnpm prisma init
    3. Change the provider to sqlite and set the DATABASE_URL in your .env file to file:./dev.db
    4. Use the following Schema
    5. model Post {
        id        Int      @id @default(autoincrement())
        title     String
        content   String
        createdAt DateTime @default(now())
      }
    6. Run the migration pnpm prisma migrate dev --name intial
    7. Seed the database with some data
    8. Modify the schema as follows:
    9. model Post {
        id        Int      @id @default(autoincrement())
        title     String
        content   String
        createdAt DateTime @default(now())
        tags      String
      }
    10. Run the migration 
    11. Could you migrate? If not, can you fix the schema and migrate again!
    12. Re-seed the data with new structure
    13. Check out changes with prisma studio
    14. Roll back the migration

     

    Discuss with OthersAsk questions, share your thoughts, and discuss with other learners.

    Loading discussion ...
    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

    No hints available.

    No hints available.

    Pie Logo
    Exercise: Seeding and Migrations
    by Tomas Trescak
    Pie Logo
    Exercise: 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