1 00:00:00,580 --> 00:00:05,010 We've updated the common module and now all of our different events expect to be given a version number. 2 00:00:05,140 --> 00:00:07,320 We're going to now go around our ticket service. 3 00:00:07,390 --> 00:00:10,840 We're going to see that there are a couple locations inside of here where we are trying to publish an 4 00:00:10,840 --> 00:00:15,820 event and chances are when we publish those events we are specifying the exact properties to include 5 00:00:16,390 --> 00:00:20,980 and chances are we are not including the version number inside of any of those published that's. 6 00:00:20,980 --> 00:00:24,940 So we have to go through and just found wherever we are publishing any event and make sure we include 7 00:00:24,940 --> 00:00:29,200 the version number we're going to first get started inside of our routes directory inside if you're 8 00:00:29,210 --> 00:00:32,850 going to find the new test file as soon as I open this up. 9 00:00:32,860 --> 00:00:37,690 I'll see that there is an air right down here where we create an instance of the ticket create a publisher 10 00:00:37,930 --> 00:00:43,420 and try to publish some information about a given ticket so if I hover over the air it's going to say 11 00:00:43,750 --> 00:00:48,590 hey you said that a event is gonna have a version and we do not provide it. 12 00:00:48,670 --> 00:00:53,750 So all we have to do is include the version of the ticket that we just created. 13 00:00:53,790 --> 00:00:57,560 It's all put in here version ticket DOD version and that's it. 14 00:00:57,600 --> 00:01:01,240 Air goes away don't save this file and close it. 15 00:01:01,280 --> 00:01:06,780 And the only other location we have to do an update is inside of update us inside of updates Yes I to 16 00:01:06,790 --> 00:01:10,050 scroll down a little bit find our ticket update a publisher. 17 00:01:10,190 --> 00:01:13,700 And so once again if we hover over the air it will tell us that we said that we were going to include 18 00:01:13,730 --> 00:01:15,360 a version property. 19 00:01:15,380 --> 00:01:20,240 So we'll put in version and include the version of the updated ticket. 20 00:01:20,240 --> 00:01:26,060 So ticket dot version like some. 21 00:01:26,190 --> 00:01:28,760 So let's save this and close this file. 22 00:01:28,910 --> 00:01:33,610 We should now be able to go back over to our terminal and restart entirely our test suite. 23 00:01:33,610 --> 00:01:38,690 I encourage you to just restart the test suite entirely so find your test suite inside the ticket service 24 00:01:38,750 --> 00:01:41,090 if you're still running it from a couple of videos ago. 25 00:01:41,270 --> 00:01:46,520 Stop it with a control C and we'll sort of back up with an NPM run test and we're just gonna make sure 26 00:01:46,520 --> 00:01:51,490 we don't get any typescript errors to make sure that typescript is not complaining at us and saying 27 00:01:51,490 --> 00:01:56,620 that we tried to create an event without providing a version property looks like all my tests are passing. 28 00:01:56,650 --> 00:02:00,650 Which means that we have done all the updates inside the ticket service correctly. 29 00:02:00,650 --> 00:02:02,940 Well so this looks good. 30 00:02:02,940 --> 00:02:07,380 I am going to close down this test suite because we're not going to come back to the ticket service 31 00:02:07,380 --> 00:02:09,190 for a little bit. 32 00:02:09,350 --> 00:02:12,690 So we're now going to start to move over to our orders service. 33 00:02:12,740 --> 00:02:16,040 Now there's a couple of different things that need to happen inside the order service. 34 00:02:16,040 --> 00:02:19,610 First off if we take a look at our ticket definition file right here. 35 00:02:19,630 --> 00:02:25,570 So inside the models directory find ticket to yes we are not including the idea of a version anywhere 36 00:02:25,570 --> 00:02:26,620 inside of here. 37 00:02:26,780 --> 00:02:32,110 Remember including the idea of a version inside of this replicated ticket model is pretty important 38 00:02:32,110 --> 00:02:36,080 because that's what's gonna make sure that we always process these events in the correct order. 39 00:02:36,100 --> 00:02:44,220 So if we think back to this diagram right here actually how about this one inside of our orders database. 40 00:02:44,220 --> 00:02:49,740 It was very important for our tickets collection to say that a ticket had an idea a price the title 41 00:02:50,040 --> 00:02:53,150 and very importantly this version thing as well. 42 00:02:53,190 --> 00:02:58,070 So it's really the tickets database and the ticket service that is producing these version numbers. 43 00:02:58,200 --> 00:03:03,690 And it is the orders service and the orders database that is going to consume these version numbers. 44 00:03:03,690 --> 00:03:08,640 So we do have to make sure that our ticket model file inside the order service includes the idea of 45 00:03:08,640 --> 00:03:13,540 a version and make sure that we include this idea of checking those version numbers whenever we try 46 00:03:13,540 --> 00:03:20,380 to somehow process an event we do also have to make sure that we wire up all this versioning stuff for 47 00:03:20,380 --> 00:03:21,670 our order as well. 48 00:03:21,670 --> 00:03:26,170 So the order model file very similar to what we had done just a moment ago inside of our ticket file 49 00:03:26,200 --> 00:03:27,540 back inside the ticket service. 50 00:03:27,610 --> 00:03:33,310 We are going to eventually include that Mongoose updates if version present or whatever was called Mongoose 51 00:03:33,310 --> 00:03:37,960 update if present whatever it was whatever that module is called We have to wire that up to our order 52 00:03:37,960 --> 00:03:45,660 model in the exact same way that we did back inside the ticket service specifically the ticket to yes 53 00:03:45,660 --> 00:03:46,080 file. 54 00:03:46,290 --> 00:03:51,290 So we've got to go through this plugin setup and then wired up to the schema in the same way. 55 00:03:51,320 --> 00:03:53,240 So a little bit of work to do inside the order service. 56 00:03:53,240 --> 00:03:55,130 Let's take care of this in just a moment.