How to deploy projection changes to staging systems


I would like to know how you guys deploy your projection changes from your test environment to production.

The only thing right now for me would be triggering a post deployment script that updates/creates the projections the way I want. Is this a solution that is used by other people or is there some feature of event store that would let you do something similar like this?


To be honest, I haven’t got as far as production yet. And this is still on my “to test” list. But theoretically…

Changes made to a projection via the UI appear as events in the projection’s own stream. So I presumed that I could change my projection by writing events to that stream. So my intention is to play the events for the projection itself from the ES instance in my staging environment to prod.

I trust that I’ll be able to use the same scripts that I use for duplicating / migrating entity streams.

With regard to the timing of this, I would not be triggering it post-deployment. My projections will be versioned (by name unless somebody can point out a better way), so I will not be changing existing projections. Therefore, I can have my new version projections running side-by-side with the previous ones before other front/back-end elements are deployed. Switching to the new projections is a config change.

Hope that gives you some ideas. I still need to test the “replay the projection’s-own-stream events” theory but I have faith in EventStore…

Sadly it appears you cannot write to a projection by adding an event to its stream :frowning:
I guess that event stream is written after the real work is done.

In which case I will be using the API to submit my projection changes to ES instances in other environments.

But still versioned and deployed side-by-side as per my previous post.

The is a CLI tool for paid customers but I don’t think it allows updating projections, but there are new and delete.

The HTTP API though contains enough methods to do everything you want. Basically, the web UI uses the same API.

The projections endpoint of the API also has no update, the CLI tool might behave similarly since the CLI tool is just the HTTP API client.

Ah ok, this is a good tip.
But the HTTP Api must have an update endpoint, as the WebUI most
likely makes a PUT to the projection. At least there is a PUT request
when you update a projection in the API. Maybe this is not documented
or something like that.

Maybe writing an own cli tool would be a good idea. This should be
straight forward, just update/create/delete some projections. I was
just curious if there are any hidden gems in eventstore =)

Instead of updating a projection, why not make a brand new one? Then when no one is listening to the old one anymore - because all the servers the old app code was running on are dead - delete the old projection.

This might be a good idea in general, but I think this might get very
confusing at some point, as I am pretty sure that a lot of old unused
projections will stay where they are out of fear of breaking
something. For example if you have a new event with a property more,
it is just easier to update the projection and deploy. As I am not
very experienced with eventstore, this would be my way to go. For more
complex changes, creating a new one is certainly better.

There is an existing projections CLI tool IIRC

Not in the free distribution for Windows, I checked yesterday.

Ah ok this makes sense. I will bring it up at a meeting whether we should:

  1. make it more widely known that it exists in paid tooling

  2. make it available in OSS tooling