So, I instructed you to install a specific version of Drizzle Kit for this tutorial, but you might have already noticed in the previous chapter that if you try and run Database Studio, you're going to run into a message here. So I'm gonna go ahead and run my studio here and there we go. It says Drizzle Studio requires a new version of Drizzle Kit. Please install the latest version and try again. So I'm gonna go ahead and teach you how to migrate to the newest version and it's actually extremely simple.
So choose your package manager, as you know I'm using bun, so I'm gonna go ahead and copy that. Let's go ahead inside of our terminal, Let me expand my screen a bit. Looks like I didn't copy, my apologies. So, bun add drizzle kit latest-D. And now if you take a look inside of your drizzle kit, There we go.
So in my case, I have 0.21.1. All that matters for you is that it's at least 21, right? If you're watching this in the future, they might even go to 22 or something, right? But what's important is that it's at least 21 for this change that we are doing in this chapter. And what you can also do if you want to is push your Drizzle ORM versions as well.
So here is my Drizzle ORM version. So let me do bun add Drizzle ORM latest. Let me add that. There we go. Looks like I am still in the same version, I believe.
And I'm also going to update Neo Database Serverless. So the only reason I'm doing this is to ensure that there are no more changes I will later have to cover. So let's go ahead and try this. So Database Serverless at latest. And let me go ahead and see the package.json now to see the versions.
All right, so some slight patch version change on the Neon Database Serverless here and the Drizzle kit is the large breaking change here. So if you want to, you can go ahead and install the Neon Database Serverless 0.9.3 if yours is too big of a change. But I just want to be clear with my versions at the moment. So now that we have this change, I recommend you to do the following. So if you're using bun, you can do bun install dash dash force.
So what force is going to do, I think we can do that with help here, or maybe bun install help. There we go. So if I add ''-force'' it will always request the latest version from the registry and reinstall all dependencies. And it's also going to remove the node modules and it's going to remove the bun lock file. So if you're using bun, go ahead and do that.
It's not required, you don't have to do it but just in case that maybe some cache is left over. And if you're using npm you can just do npm install and just remove node modules right so you have the newest versions and now I want you to go inside of drizzle.config.ts and inside of here we now have some errors. Lucky for us they are very simple to fix. So we have this guide how to migrate to 0.21.0 and it's inside of the Drizzle kit right here. Upgrading.
So first of all, let's go ahead. We're gonna do this later. Let's go ahead and do this. Update the Drizzle file. So it's actually much simpler now.
We're not going to manually specify the driver and this is no longer connection string instead it's URL and we have to add the dialect which is PostgreSQL that is it that is our change And now what we have to do is we have to go inside of our package.json and we have to modify our scripts here. So the scripts actually become much much simpler. We just need this and for the migrate we just need DrizzleKit migrate. That is it. Those are our changes.
So here's what I'm going to do now. So I'm going to go ahead and remove the entire drizzle folder simply because it's easier for us to do that. There is the official guide if you are in production. So you can run drizzle kit up if you want to update the schemas, right? But you know, this is just a tutorial.
It's easier to just remove that drizzle file. And now let's, for example, go inside of our database schema and let's export const update, pg table, update, ID text, ID with a primary key. And I'm gonna add a name text name like this. So I'm just creating a dummy table here and now let's try our new scripts. So bun run database generate.
There we go. So it created it in the exact same folder, Drizzle. Right? So we no longer need that script. So you can go inside of the scripts and you can now remove the migrate.ts.
But you can leave the folder scripts because we're gonna use it later and now what you have to do is bun run database migrate and as you can see right here it automatically sets the driver and it automatically read our config file. Let's go ahead and check it out. So inside of my Neon console, ignore all of this tables that I have because I already finished the project, right? So I'm coming back to this after I finish the project. What's important is that here is our update table with ID and name.
So that is it. That is the entire migration process. So every time in the tutorial that you see me run any more scripts, you're not even gonna notice any changes because we map them under database generate and database migrate, right? So you actually don't even know that in the rest of my tutorial, I have something else written here. But what's important for you is that you have this change right here and you can now safely continue and follow the tutorial with the newest versions and the best part of it all of course let's confirm Von Run Database Studio should now work just fine so if I go here there we go again I have a bunch of records here because I already finished the tutorial at this point but our studio is now working great great job