Modernizing a 10-year-old SQL Server project using Prisma | Interview | Luís Rudge & Daniel Norman

Modernizing a 10-year-old SQL Server project using Prisma | Interview | Luís Rudge & Daniel Norman

Show Video

okay i'm now very excited to do an interview with lewis rudge lewis roge has been a father and developer for many years he currently works remotely as a front-end engineer for browse.com a canadian company he's also a professor at platy where he creates courses for those who want to learn more about main development technologies he's the co-founder of the company dead poster som no cuado focusing on bringing innovations to the residential decoration market and finally lewis has also been a very active prisma community member and so that's why we're really excited to have him here today to share his experiences working with prisma in different environments and different technology stacks so welcome louis thank you thank you very much for having me here i'm very excited about uh sharing a bit of my experience with you and yeah let's go all right let's get into it so the first question i have for you is how do you use prisma these days right so as i mentioned i am a co-founder of a brazilian company we do sort of we're innovating the way you can decorate your house and all of the order management's back office application and of course the e-commerce part of this is handled by a database that is managed with prisma right so that's how i'm using right now uh i'm actually migrating a very very old project that i built uh with other technologies like old technologies let's call it done technologies to prisma as well so it's very exciting to be able to have the experience of working in very very new projects with prisma but also bringing a project that was created nine years ago to the current technology stack that is being used today so it's very exciting i see and i'm curious to hear what technology stack did you use to build that project 10 years ago yeah i actually use uh net framework i'm not even sure about the version uh with sql server it's pro it's what i learned to develop on and i i'm probably developing professionally for for i know 10 years so it was my first actual project that i built from scratch alone without any help from any other person right so i used whatever i was feeling comfortable at the time uh and of course things changed uh priors changed uh my knowledge changed as well and as well as i was improving and kind of changing the tech stack that that it was my go-to tech stack that project stayed the same because the project was done in 2016 i think there were there were no updates since then but every now and then you have to go there and let just a bit of just just one tiny thing right so i don't actually touch it anymore but now i want to bring it to the 21st century right i want to develop something that is better for the people that are using the project but also myself because every time that i have to do a tiny change is a huge hurdle for me and i'm curious so this 10 year old project it's still deployed and it's still serving users yeah absolutely yeah we have close to a thousand active users a month it's not an it's not a lot but for the niche that is trying to uh work for it's it's pretty much uh everyone that is using it i see and and what was your experience sort of modernizing this 10 year old project with prisma did you use for example introspection to get up and running quickly with prisma what was sort of the approach there so i tried to do this multiple times with different technologies before prisoner right i tried to okay i'm going to rebuild this with node and whatever new aura or im there was at the time but every time i was trying to do this i hit a roadblock that was basically i have to map my entire database and i'm not feeling it right uh so when prisma came in the interest when i started looking at prisma because pretty much i started looking pretty recently but when i actually look at the way prism works and the way introspection works and i know other tools have other introspection tools as well but when i saw it at prisma it kind of clicked to me so i did a quick test uh once you enable uh once sql server preview was on i did a quick test running introspection pointed to that database and i had my entire model in i don't know two minutes i think so that was very fascinating that that was basically i have this very very old project that is working but i don't want to change i don't want to create a lot of stuff for it right so i just typed uh i i think at the time i actually i don't remember the the the introspection comment at the time right now is db po right so i i typed like tvpo or equivalent and basically all my models were there all my types were there i could basically access my data anywhere i wanted and that was very exciting i see i got you and and just to fill in some of the viewers who might not be familiar with this idea of introspection so introspection is a concept that is sort of deeply integrated into prisma and the idea is that you basically point prisma to the database url and you either use the prismadb pull command or the prisma introspect command and what that will do is prisma will then connect to the database analyze all of its schema essentially introspecting the database schema and based on that it will populate your prisma schema and so i guess based on the experience that you've just shared lewis that the idea there was you introspected the database it gave you this prisma schema from which you could generate prismaclient and then suddenly you can do all sorts of operations against the database and make sure that you you're doing them in a type safe way meaning that you won't try to write to a field that doesn't exist or you won't try to read from a field that doesn't exist is that a pretty much a correct representation of what you were doing in that project that's exactly it and that was the main hurdle i had when i was trying to to migrate this project in the first times having all my all my data with all my relationships and all because it's a very it's not super complex but it has enough complexity that it was kind of yeah i'm not gonna do that with other projects and when i could just like run db poll and all my models types etc over there including relationships everything it was just like so easy i had to do it i'm glad to hear and i'm curious where some of the features that you plan are some of the features that you plan on working on are front end changes and and features that involve both changes to the front end and the back end or these purely uh front end changes what kind of changes uh do you plan on carrying out and how does that influence sort of your workflow as you sort of modernize this old stack because i imagine that you know no one wants to just modernize an old project just for the sake of it i mean it can be a learning experience but oftentimes as developers you know we we have concrete goals that we want to reach we want to add a new feature and so on how does that sort of fit into what you were doing with all of the introspection yeah great question so there's uh the answer i think it's twofold right one as a developer of course i want to have something that i can actually uh manage and now every time i have to do a change i have to open up a vm because i'm on mac right now i have to open up a windows vm with visual studio and open and change everything whatever i need to change and then do a git pull and get push and after that the ci takes care of it right but i still have to have this vm with me i still have to have all this hurdle to do tiny updates right and when i say tiny place they are very very tiny sometimes i just go into github and change it there and now like cross my fingers that will work but sometimes if i have a more considerate change i have to actually open up to here right so yes i want to make my life easier from now on and that to do that i think i need to to bring this project to a tech stack that i'm comfortable today but it's not only that i could live with the vm for the next i don't know five ten years right but i i actually wanna teach something right i'm i'm planning on having uh i don't know youtube channel or series or videos or something what i can actually show how you can modernize your 10 year your 15 year old uh project with tools like prisma right so it's kind of twofold here yes i want to have something that is easier for me to manage from now on but i also want to help others do the same because i know there's a lot of people that created projects 10 15 years ago and they want to bring this project to this year to this century but it's sometimes hard right so if i can help these people do the same yeah that's really nice of you and would you say that in this project the front end and the back end are decoupled are they sort of decoupled and do they use a rest api or is there something like more like the old-school sort of server-side rendering or the php style where essentially you're doing back-end logic and then spitting out uh html that is then rendered by the browser what sort of approach there because i'm sure that might influence how you approach sort of modernizing it because if the front end and the back end are really decoupled with a rest api then you can essentially just rebuild the whole back and the rest api using a modern technology and then still rely um on the existing front end and then slowly like make the change to the front end to whatever new stack that you want to use yeah that's uh that's a great question no no this project specifically it was built with uh net mvc framework so all the html is server rendered uh there's just a bit of logic in the client i think at the time i used a library called knockout js which at the time was created by someone at microsoft as well so i was a very microsoft-ish guy so i used that but i want to bring to something that i people actually use today right so react that's my person like my personal stack is react node and and tools like this so it's going to be a full rewrite and because it's my project and there's no like third party involved i think i can just do it honestly it's mine uh so worst case scenario i just don't publish it and it stays the same right uh but i went to to to bring everything to you to this day create a very nice rest api probably graphical i'm not sure right now but definitely splitting out backhand from the front end because that's one one of the things that is not in project right now got it interesting and and so you mentioned this 10 year old project but obviously i think as your experience tells you've worked with prisma and also in other projects i'm very curious to hear since you've used it used prisma in a bunch of different projects how would you compare the experience using prisma in a green field in a new project comparing that to adopting prismane and existing in a brownfield project what was some of the differences that you sort of encountered in that experience right so i think that that's actually a great question i think you can consider i'm only talking about my experience here right but after i run the introspection comment and i did all my mappings right because when i created that database it was created in the way that dotnet developers create databases at the time so everything was plural every uh column name was like in pascal case and this type of stuff is there right and i want to change that because i don't want my code because when you generate with the prisma clients it generates exactly how it is in the database right so i'm actually i think the brown my brownfield experience is running introspection and mapping my entire model after that honestly i can't consider this a brownfield project anymore because now i have all my database at the tips of my fingers and it's a new project i can create anything i want i can access that data any any way i want so honestly i think it's a brownfield project until we have every mapping done because after that it's really up to you do you want to create a new project do you want to bring the exact same front end to your project fine right uh so i think what and this is the difference when i start creating the other project my current project is i start from scratch and i just use because i'm using the adapter not i not even running migrations i just create my model and access my data and that's pretty much it right so my experience between brownfield and in greenfield is basically it is brownfield up until you map your data after that it's basically like any other prisma project you're working on everything works your client is perfectly mapped uh you can query and and send instructions to your database like you would with any other prism project so honestly it's brownfield until you map your stuff after that it's just greenfield yeah and um i think it's maybe worth pointing out you spoke about mapping in case viewers aren't familiar so essentially when in the prisma schema when you define a new field that maps onto both your prisma client and also to your database schema and so when when you have a situation in which you want to actually have a different name in your database schema and prismaclient for example imagine first name imagine that it was first underscore name and that's how it was in the database and you introspect that by default prisma will pick that up and you will have a prisma underscore sorry a first name underscore a first underscore name uh field and and what what mapping allows you to do is essentially it allows you to to to control how you want things named in your prisma client without changing the database schema is that what you are doing essentially you are basically doing these maps in order to maintain the database schema as it is while still sort of adopting new naming convention that fits a more modern style of naming things inside your sort of cli your application code correct yeah for example i had like a users table and the id was uh id uppercase right and that's not the way i want to work not today anyway i want to have like the user object with the like lowercase id first name as in f lowercase and uppercase and all of this my database not was not built to to be like this right so what i did is after i run the introspection commands the db pro comments i just go ahead and i go in the into the model and say okay this model here i want to map this name users to user and map to the tape users right and table sorry table users and that's pretty much what i did and that was a long day to do all of this because it's a bunch of tables a bunch of fields but it's worth it at the end of the day you have everything you want exactly the way one wanted named exactly the way you want and then it's just easier for example i'm running with a node.js right now so i'm just using javascript conventions for namings and it makes my life so much easier got it thank you for sharing um and how how is your experience working with different databases using prisma bean i mean databases especially if you compare say mongodb and sql server or postgres for that matter they have very very a very different paradigm and and one of the sort of core goals of prisma is really to provide you a single way to um really interact with different databases and of course by by sort of doing that prisoner tries to abstract a lot of the details for you while still giving you the optional complexity to control things when you need like you mentioned with the map and there's many more sort of examples of this kind of like optional complexity that you have in prisma so i'm just that was a very long prelude to the question what is your experience being sort of working with different databases that have a different paradigm using prisma yeah i think i started using prisma testing prisma with sqlite right and then i of course i tried with a pet project with uh postgres but i don't use post rogues in production anywhere so i wasn't very interested in that but then i saw that i think the first one the first preview one was uh the sql server right so i started testing with kl server and then we talked about my experience with that and then i saw the new preview for because that's that's how i me personally that's how i want to start creating apps right now with easy no migrations no sql scripts no nothing right and i know it's not perfect for every scenario but it works for my scenario so i have experience running when i say production payloads in both of them it's not kind of production in one of them only in the mongol and my experience is prisma doesn't get in my way at all i had it and i'm running preview here sql preview and preview and even then it fits my my work uh my workflow perfectly i think the only thing that was missing in my current workflow is in better types and and i know for and i know this is this is coming or this was already launched i think there is back for it i don't believe it's like yeah i believe in the 2.29 release we published the spec for how it's going to work um but the implementation isn't fully ready that should come but i know it's coming and that's what matters for me for now i have other ways of handling it but i think having embedded types would fix to me it would check all the boxes for me so unless honestly my experience is as soon as you set your project up it really doesn't matter what you're using because you're using prisma at the end of the day so if you know how prisma works everything underneath it works just great uh of course i have to add a disclaimer here i'm not running any very in complex uh workflows here like with huge reports or whatever i'm doing basically crud in a bunch of tables and that's pretty much it right uh so for that scenario honestly i had no issue at all with any of them i see thank you for sharing and one final question what feature do you most look forward to i guess uh you hinted already at document embedding in mongodb but i'd be curious if there's anything else or if that's the one no that's the one that's the one i think that's for the way i m because i was settled on mongol before i was settled on prisma right and the way i model my data for this uh e-commerce i had to have i have to have embedded types so because of this that's my that's my most expected uh feature for the release and of course i want them to be released in production whenever possible great well anything else you want to share before we wrap up it's been a really interesting conversation and just listening to your perspective and your experience sort of working with prisma but anything else you want to share before we wrap up now just want to say thank you for inviting me to this conversation uh and if you want to chat with me about this experience please ping me on twitter and that's pretty much it thank you so much thank you for prisma and let's get 3.0 released yeah well thank you very much luis it's been a pleasure and i hope to see you soon see ya bye

2021-09-15 22:01

Show Video

Other news