How database migrations work when using Drizzle ORM

  Рет қаралды 4,650

Web Dev Cody

Web Dev Cody

28 күн бұрын

My Products
🏗️ WDC StarterKit: wdcstarterkit.com
📖 ProjectPlannerAI: projectplannerai.com
🤖 IconGeneratorAI: icongeneratorai.com
📝 ThumbnailCritique: thumbnailcritique.com
Useful Links
💬 Discord: / discord
🔔 Newsletter: newsletter.webdevcody.com/
📁 GitHub: github.com/webdevcody
📺 Twitch: / webdevcody
🤖 Website: webdevcody.com
🐦 Twitter: / webdevcody

Пікірлер: 38
@hhhhhhhhhhhhhhhhhhhhhh
@hhhhhhhhhhhhhhhhhhhhhh 26 күн бұрын
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
@WebDevCody
@WebDevCody 26 күн бұрын
I’ll have to look more into it
@ShaneCodes
@ShaneCodes 22 күн бұрын
Do you have a link to this? Its not in their docs
@gadgetboyplaysmc
@gadgetboyplaysmc 26 күн бұрын
You've been uploading a ton dude. sick!
@elmalleable
@elmalleable 26 күн бұрын
my scripts always have db:generate:seed and db:generate:refresh (refresh to tear down and rebuild my local db)
@bnssoftware3292
@bnssoftware3292 26 күн бұрын
I really like this series of following along with your SaaS template build out. I will definitely be a buyer of it.
@iamsomraj
@iamsomraj 26 күн бұрын
Dude you really made a whole video… thanks man
@mojo6689
@mojo6689 22 күн бұрын
Great video. Clarified a lot of things that were confusing me
@buddy.abc123
@buddy.abc123 26 күн бұрын
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
@rahultech77
@rahultech77 26 күн бұрын
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
@euanmorgann
@euanmorgann 26 күн бұрын
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?
@WebDevCody
@WebDevCody 26 күн бұрын
You’d probably only want one to control running the migrations,or a separate ci cd process maybe
@peteregbujie
@peteregbujie 14 күн бұрын
Hi Cody, why did you use text and randomuuid as id in the schema instead of id: uuid("id").primaryKey().defaultRandom() ?
@hyper-stack
@hyper-stack 26 күн бұрын
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.
@rodjenihm
@rodjenihm 26 күн бұрын
If new columns are nullable, then there is no issue. If you want to make them not nullable you first have to make them nullable, then populate the data for existing records and then make them not nullable after that.
@WebDevCody
@WebDevCody 26 күн бұрын
like @rodjenihm said, but also I think you can also just add a default value to the columns.
@hyper-stack
@hyper-stack 26 күн бұрын
@@rodjenihm thank you so much!
@hyper-stack
@hyper-stack 26 күн бұрын
@@WebDevCody thank you so much!
@Flash136
@Flash136 26 күн бұрын
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.
@WebDevCody
@WebDevCody 26 күн бұрын
Prisma feels a bit better honestly. I think drizzle assumes you will do traditional migration scripts and they don’t recommend using push for production deploys
@Its-InderjeetSinghGill
@Its-InderjeetSinghGill 20 күн бұрын
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.
@WebDevCody
@WebDevCody 20 күн бұрын
I think you either need to do a drizzle kit pull so that your meta directory and journal file is correctly updated, or just keep your migration scripts around even after running them.
@Its-InderjeetSinghGill
@Its-InderjeetSinghGill 20 күн бұрын
@@WebDevCody Thanks man, I really appreciate the help, I have been pulling my hair over this for hours. I read the docs again and found out that I have to run introspect and then make sure my current schema matches with the introspection schema and then I can make changes again to my schema and do migrations with no problem.
@DouglasSouza-te9bt
@DouglasSouza-te9bt 26 күн бұрын
How often do you get discouraged with scheduling? And what do you usually do to deal with it?
@WebDevCody
@WebDevCody 26 күн бұрын
What do you mean?
@Harish-rz4gv
@Harish-rz4gv 26 күн бұрын
Did u use arc browser which Theo uses??
@WebDevCody
@WebDevCody 26 күн бұрын
No I use chrome
@SeibertSwirl
@SeibertSwirl 26 күн бұрын
First!!!! Also, love ya! You’re doing a great job❤
@WebDevCody
@WebDevCody 26 күн бұрын
Love you babe, thanks for being first. I'm going to give you something special later tonight
@SeibertSwirl
@SeibertSwirl 26 күн бұрын
@@WebDevCody sir…. Log off the internet for the day please lol
@chiubaca
@chiubaca 20 күн бұрын
Is WDC starter kit going to be open sourced ?
@WebDevCody
@WebDevCody 19 күн бұрын
Nah it’s a paid starter kit
@Stallion45
@Stallion45 22 күн бұрын
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.
@WebDevCody
@WebDevCody 22 күн бұрын
It depends on scale and data needs. In most cases postgres or mysql is the best bet. Convex if you want an all inclusive baas
@Stallion45
@Stallion45 21 күн бұрын
@@WebDevCody Thanks, as a PHP dev for almost 15 years mysql was my goto, so I've been having a good time just playing with other arms and db's but I am leaning toward Convex more often than not. It's fast, real-time, very slick dev env, and as you said it's kind of a complete package with file storage. Keep up the great videos and would love to see more with Convex.
@-lumqua-827
@-lumqua-827 26 күн бұрын
Great
@lev1ato
@lev1ato 26 күн бұрын
maybe a video about next auth pls 🥺🥺
Life After SQL (EdgeDB Is Fascinating)
15:40
Theo - t3․gg
Рет қаралды 53 М.
ISSEI funny story😂😂😂Strange World | Magic Lips💋
00:36
ISSEI / いっせい
Рет қаралды 191 МЛН
Dynamic #gadgets for math genius! #maths
00:29
FLIP FLOP Hacks
Рет қаралды 17 МЛН
Cat story: from hate to love! 😻 #cat #cute #kitten
00:40
Stocat
Рет қаралды 12 МЛН
7 React Lessons I Wish I Knew Earlier
7:30
Code Bootcamp
Рет қаралды 48 М.
This tool makes self hosting simple
5:59
Web Dev Cody
Рет қаралды 53 М.
How to Organize Your Solo Dev Project Like a Pro
7:42
CreaDev Labs
Рет қаралды 12 М.
Learn Drizzle ORM in 13 mins (crash course)
14:00
Neon
Рет қаралды 18 М.
Gitlab DELETING Production Databases | Prime Reacts
17:27
ThePrimeTime
Рет қаралды 295 М.
That's It, I'm Done With Serverless*
23:58
Theo - t3․gg
Рет қаралды 193 М.
The Pattern You MUST Learn in .NET
20:48
Nick Chapsas
Рет қаралды 75 М.
What Your GitHub Says About You | LIVE from Brazil
19:00
ThePrimeTime
Рет қаралды 141 М.
The Reality Behind Web Developer Salaries 2024
8:01
Chris Sean
Рет қаралды 13 М.
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Рет қаралды 26 М.
ISSEI funny story😂😂😂Strange World | Magic Lips💋
00:36
ISSEI / いっせい
Рет қаралды 191 МЛН