Add Prisma to Existing Database

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024

ความคิดเห็น • 8

  • @victormafra5309
    @victormafra5309 6 หลายเดือนก่อน +1

    Great video!!! I have a doubt, if I change columns in my database (adding some column, for example). When I try to migrate, I receive this:
    - Drift detected: Your database schema is not in sync with your migration history. Do you know how I would sync it? Is it possible to make changes in the database and then save it in migrations without losing every data?
    We need to reset the MySQL database at "localhost:3306"
    Do you want to continue? All data will be lost.

    • @alexrusin
      @alexrusin  6 หลายเดือนก่อน +1

      Thank you!. Yeah, this is what I don't like about Prisma migrations (I think Sequelize is much better in this sense). It may generate migration that will require database reset. First, I would check generated migration file itself. That's why I use a flow where I create migration file first (prisma migrate dev --create-only). Sometimes prisma may drop a column and create a new one when you just need to rename a column. What I do then is update SQL itself to change migration to actually rename a column. So the idea is to try to change destructive migration into a non-destructive one. Second, when developing it is a good idea to have a seeder so in case you actually reset the database you can seed it fast. Finally, in production you need to use `prisma migrate deploy` command. I don't think this will prompt you to reset the database.

  • @SKEYZORIK
    @SKEYZORIK 6 หลายเดือนก่อน +1

    Finally thank you

    • @alexrusin
      @alexrusin  6 หลายเดือนก่อน

      You are welcome!

  • @SamChaneyProductions
    @SamChaneyProductions หลายเดือนก่อน

    This is creating new tables in an empty database, not adding Prisma to an existing database with extant tables

    • @alexrusin
      @alexrusin  หลายเดือนก่อน

      Check out 0:24 I talk about existing database with 2 tables.

  • @lofi2604
    @lofi2604 5 หลายเดือนก่อน +1

    Wo wo wooo 🎉🎉🎉 nice bro

    • @alexrusin
      @alexrusin  5 หลายเดือนก่อน

      Thank you!