We've updated the common module and now all of our different events expect to be given a version number.
We're going to now go around our ticket service.
We're going to see that there are a couple locations inside of here where we are trying to publish an
event and chances are when we publish those events we are specifying the exact properties to include
and chances are we are not including the version number inside of any of those published that's.
So we have to go through and just found wherever we are publishing any event and make sure we include
the version number we're going to first get started inside of our routes directory inside if you're
going to find the new test file as soon as I open this up.
I'll see that there is an air right down here where we create an instance of the ticket create a publisher
and try to publish some information about a given ticket so if I hover over the air it's going to say
hey you said that a event is gonna have a version and we do not provide it.
So all we have to do is include the version of the ticket that we just created.
It's all put in here version ticket DOD version and that's it.
Air goes away don't save this file and close it.
And the only other location we have to do an update is inside of update us inside of updates Yes I to
scroll down a little bit find our ticket update a publisher.
And so once again if we hover over the air it will tell us that we said that we were going to include
a version property.
So we'll put in version and include the version of the updated ticket.
So ticket dot version like some.
So let's save this and close this file.
We should now be able to go back over to our terminal and restart entirely our test suite.
I encourage you to just restart the test suite entirely so find your test suite inside the ticket service
if you're still running it from a couple of videos ago.
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
we don't get any typescript errors to make sure that typescript is not complaining at us and saying
that we tried to create an event without providing a version property looks like all my tests are passing.
Which means that we have done all the updates inside the ticket service correctly.
Well so this looks good.
I am going to close down this test suite because we're not going to come back to the ticket service
for a little bit.
So we're now going to start to move over to our orders service.
Now there's a couple of different things that need to happen inside the order service.
First off if we take a look at our ticket definition file right here.
So inside the models directory find ticket to yes we are not including the idea of a version anywhere
inside of here.
Remember including the idea of a version inside of this replicated ticket model is pretty important
because that's what's gonna make sure that we always process these events in the correct order.
So if we think back to this diagram right here actually how about this one inside of our orders database.
It was very important for our tickets collection to say that a ticket had an idea a price the title
and very importantly this version thing as well.
So it's really the tickets database and the ticket service that is producing these version numbers.
And it is the orders service and the orders database that is going to consume these version numbers.
So we do have to make sure that our ticket model file inside the order service includes the idea of
a version and make sure that we include this idea of checking those version numbers whenever we try
to somehow process an event we do also have to make sure that we wire up all this versioning stuff for
our order as well.
So the order model file very similar to what we had done just a moment ago inside of our ticket file
back inside the ticket service.
We are going to eventually include that Mongoose updates if version present or whatever was called Mongoose
update if present whatever it was whatever that module is called We have to wire that up to our order
model in the exact same way that we did back inside the ticket service specifically the ticket to yes
file.
So we've got to go through this plugin setup and then wired up to the schema in the same way.
So a little bit of work to do inside the order service.
Let's take care of this in just a moment.