0:00 All right, so in this lecture, we're gonna go ahead 0:02 and implement database 0:03 migrations so that we can generate our actual 0:07 schema that BetterAuth needs in order to persist our authentication data 0:11 to the database. Now, the first step in doing this is going to 0:15 be to create a separate instance of our BetterAuth instance 0:20 that the BetterAuth CLI can actually read in. 0:23 Now, BetterAuth actually offers a CLI tool 0:27 in order to parse your BetterAuth instance, and what it will 0:31 do is it will actually parse the BetterAuth instance and based off of the 0:34 database provider that you're using, it'll automatically generate 0:39 respective types for the ORM that you're using. 0:42 Now, in our case, we're using Drizzle ORM, so there's gonna be a special 0:46 schema that we need to generate for Drizzle ORM in order to generate database 0:50 migrations as well as generate the underlying TypeScript types that 0:54 our code will use in order to have end-to-end type safety 0:58 with our database schema and respective types in the code. 1:02 So this might sound a little confusing at first, however, let's walk through it and 1:06 we'll see how it all fits together. 1:08 Now, importantly, we have to generate a separate BetterAuth 1:11 instance than the one 1:12 we've already set up in the app module, and that's because by default, 1:16 the BetterAuth CLI today cannot actually parse 1:20 this BetterAuth instance that we have in the app module with our 1:24 dynamic NestJS configuration. Now, this might change in the 1:27 future as NestJS BetterAuth evolves, and I will update this 1:31 lecture accordingly if that's the case. 1:33 For now, however, we're gonna simply generate a dummy 1:36 instance of it that will 1:37 be compatible with the BetterAuth CLI. 1:40 So in order to do this, let's go ahead and create a separate folder in source, 1:44 and 1:44 we're gonna call this the auth folder.
The rest of the transcript is for members.
Sign in