Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Deleting event streams #157

Closed
mwillema opened this issue Mar 6, 2019 · 3 comments
Closed

[question] Deleting event streams #157

mwillema opened this issue Mar 6, 2019 · 3 comments

Comments

@mwillema
Copy link

mwillema commented Mar 6, 2019

From what I've seen there's no way to delete event streams, is that right?

I guess I can always do it manually be removing the proper records from the underlying database.

I know that conceptually events should never be removed. However I'm migrating a legacy system from which I import events. So as the development is making progress, I find myself re-importing these events from the legacy system over and over.

@slashdotdash
Copy link
Member

slashdotdash commented Mar 6, 2019

No, it's not supported yet. I can add it as a feature request. For example, Greg Young's Event Store supports soft and hard deletion of streams.

I guess I can always do it manually be removing the proper records from the underlying database.

There are Postgres rules on the events tables to prevent updates and deletes. You would need to drop those rules before attempting to delete any events.

DROP RULE no_update_stream_events ON stream_events;
DROP RULE no_delete_stream_events ON stream_events;
DROP RULE no_update_events ON events;
DROP RULE no_delete_events ON events;

Be warned that deleting events will break the event store.

My recommendation would be to replace the events with empty data and set the event type as a deleted event struct (e.g. Elixir.MyApp.DeletedEvent).

UPDATE events 
SET 
  event_type = 'Elixir.MyApp.DeletedEvent', 
  data = convert_to('{}', current_setting('server_encoding')), 
  metadata = convert_to('{}', current_setting('server_encoding'))
WHERE event_id = '<event_id>';

You would need to define a deleted event module:

defmodule MyApp.DeletedEvent do
  defstruct [:data]
end

@LostKobrakai
Copy link

I'd be interesting in that as well, as deleting streams can be a good approach for handling data, which are required to be deletable by law.

@slashdotdash
Copy link
Member

Closing this issue. I've added a new "Event stream deletion" feature proposal in #170.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants