![]() Step 1: Dump the prod database + import the schema From there, I could insert the old data into the new database, and then swap out production databases. The best option was to just re-create a new database with the same tables but with different primary key data types. ![]() I realized that there's not a lot of information out there for how to migrate an existing production database with over 40 tables from auto-incremented IDs to UUIDs 2, so here's me documenting how I got it done. If you're interested in other approaches for generating identities in Domain-Driven Design, see "Chapter 5: Entities" in Vaughn Vernon's " Implementing Domain-Driven Design" for a more detailed discussion. This technique also simplifies how we can use Domain Events to allow other subdomains and bounded contexts to react to changes in our systems. With auto-incremented ids, that's not possible (unless of course, we were to do some hacky things).īeing able to create Domain Objects without having to rely on a db connection is desireable because it means that our unit tests can run really quickly, and it's a good idea to separate concerns between creating objects and persisting objects. The reason for the migration is that we want the Domain Layer 1 code to be able create Domain Objects without having to rely on a round-trip to the database. In my domain-driven design journey, I've come to realize that auto-incremented IDs just aren't gonna cut it for me anymore for my Sequelize + Node.js + TypeScript backend. Check it out if you liked this post.Īlso from the Domain-Driven Design with TypeScript article series. Set to one of the built-in generators - uuid.mathRNG (all platforms), uuid.nodeRNG (node.js only), uuid.whatwgRNG (WebKit only) - or a custom function that returns an array of byte values.Įxample: Generate string UUID with fully-specified options uuid.This is part of the Domain-Driven Design w/ TypeScript & Node.js course.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |