How database migrations work when using Drizzle ORM

preview_player
Показать описание
My Products

Useful Links
Рекомендации по теме
Комментарии
Автор

The team behind Drizzle actually just added a "migrate" command to drizzle-kit's beta version on April 26th which will likely make this more straightforward if you're not in need of some custom behavior. This way definitely still works too but just figured I'd point it out

hhhhhhhhhhhhhhhhhhhhhh
Автор

You've been uploading a ton dude. sick!

gadgetboyplaysmc
Автор

Dude you really made a whole video… thanks man

iamsomraj
Автор

I really like this series of following along with your SaaS template build out. I will definitely be a buyer of it.

bnssoftware
Автор

just came to say this helped me, thanks!

mantas
Автор

The only annoying thing about Drizzle is their push command when prototyping. With Prisma, the push command will let you keep pushing to the database as long as it isn't going to delete any data. With Drizzle, the push command will ask for your intervention even when a table has been renamed or has been removed from the schema. This is quite annoying when prototyping because any major change to the database structure requires you to manually clear unused tables. Also, Drizzle just doesn't seem to know when data deletion is possible. You have to keep telling it that yes this push operation is safe, go ahead. Prototyping with Prisma is a breeze. I just need to generate migrations IF and WHEN I actually already want/need to.

Flash
Автор

Great video. Clarified a lot of things that were confusing me

mojo
Автор

Thanks for uploading this. I was running db:push manually as i wasn't able to figure out how to run this automatically on CI

rahultech
Автор

my scripts always have db:generate:seed and db:generate:refresh (refresh to tear down and rebuild my local db)

elmalleable
Автор

Is something wrong with me? Once I understood Go earlier this year I'm not interested in server side js 😭

I've always done C# but for side projects I still used node. Now node is for frontend and Go is backend. What's wrong with me?

The only thing keeping me in js land is the ui components like Shadcn and Aceternity

charliesta.abc
Автор

I have a question. What if, let's say my hello table, already had some data in it, and I added some more columns into the hello schema. How can I migrate the changes but still manage to keep all my existing data in the hello table.

hyper-stack
Автор

Awesome video 🙏
One question though,
Since this is a monorepo if you had multiple apps in there pointing at the same shared DB, would you still run migrations on start for all of them?

euanmorgann
Автор

Now my question is,
i have a nodejs microservice which is a backend for frontend, and i'm deploying with coolify, so when i upload de code to gh, a webhook automatically calls my coolify installed in my vps, and this runs the docker i have, this docker firstly builds the project, and then deploys it to a clean machine, so my way of doing automated migrations is copying the migration folder to the new machine with just the JS files, and then run the migrations before i run express, and in case this fails, the app shuts down.

I had to do it this way because of deploying the clean build files in the dist directory instead of the TS ones and running a dev server on it.

Is this okay?

I've been having a hard time learning the best practices, and the deploy process and automation of it is being REALLY like REALLY hard, there's so much stuff to have in mind, and the bare thought of 'Where in the lifecycle of the deploy process should i do the migrations, and how the f*** do i automate them' was really tough.

I now have it running and it is going flawlessly, i was able to install a pgAdmin in coolify that connects to the PostgreSQL i have, so i could monitor how the migrations were working and everything seems fine, but i lack the expretisse to know if this methodology is okay, so i'd love to know if the workflow i described is good enough so i can sleep at night xdd.

kueogdz
Автор

Bro I have a question I don't know if you can help me. If you are working on a dev branch an run generate and migrate all works fine but if you go to production branch and do the merge and then run the migrate it will do all the migrations that are not actually applied? Or you have to run one by one manually?

choskas
Автор

Hi Cody, why did you use text and randomuuid as id in the schema instead of id: ?

ogbillity
Автор

Would be cool if you did a video on how and why you choose your database options for projects. Drizzle, Prisma, Convex…, mysql, psgr etc. I’ve used mysql for years, and been learning the others, but this is a major frustration point t as I keep second guessing myself and wondering if my choice is the right choice. From video to video on this channel and others it seems the choice is random. Just one of my obstacles that keeps me from finishing projects.

Stallion
Автор

First!!!! Also, love ya! You’re doing a great job❤

SeibertSwirl
Автор

Hi, I love your videos, I have one question about migrations. I followed the pattern showing in your video works great but just to make sure and test each edge case I delete migrations folder form my project after generating and migrating previously and then I re generated migrations and ran migrate script, but it throw an error like SQL_INPUT_ERROR: SQL input error: table `customers` already exists. It looks like it lost the track of changes I made earlier in the schema. A quick answer would be really appreciated.

Its-InderjeetSinghGill
Автор

How often do you get discouraged with scheduling? And what do you usually do to deal with it?

DouglasSouza-tebt
Автор

Is WDC starter kit going to be open sourced ?

chiubaca