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

can't write unknown attribute event_id #1643

Closed
jmkoni opened this issue Jul 12, 2023 · 2 comments
Closed

can't write unknown attribute event_id #1643

jmkoni opened this issue Jul 12, 2023 · 2 comments

Comments

@jmkoni
Copy link

jmkoni commented Jul 12, 2023

I'm working on upgrading a project to Ruby 3 and am currently running into issues with RailsEventStore. Using the example that is in the docs, here is what happens for me (same thing happens with our own events):

[3] pry> OrderPlaced = Class.new(RailsEventStore::Event)
AccountingHelper::Transaction::OrderPlaced < RubyEventStore::Event
[4] pry> stream_name = "order_1"
[4] pry> stream_name = "order_1"
event =Placed.new(data: { order_id: 1, order_data: "sample", festival_id: "b2d506fd-409d-4ec7-b02f-c6d2295c7edd" })
OrderPlaced.new(data: { order_id: 1, order_data: "sample", festival_id: "b2d506fd-409d-4ec7-b02f-c6d2295c7edd" })
#<OrderPlaced:0x0000000126c67240 @event_id="c8df9997-a7b7-41cc-9f87-d1d83543fd10", @metadata=#<RubyEventStore::Metadata:0x0000000126c66fe8 @h={}>, @data={:order_id=>1, :order_data=>"sample", :festival_id=>"b2d506fd-409d-4ec7-b02f-c6d2295c7edd"}>
[5] pry> event_store.publish(event, stream_name: stream_name)
ActiveModel::MissingAttributeError: can't write unknown attribute `event_id`

I bumped us from rails_event_store 1.3.1 to 2.1.0. Currently running Rails 6.1 and Ruby 3.0.6. I am not sure how to fix this issue.

@mostlyobvious
Copy link
Member

mostlyobvious commented Jul 17, 2023

ActiveModel::MissingAttributeError: can't write unknown attribute event_id

I get this error message when I try to run RES 2.x code on database schema of RES 1.3.x.

There was a pretty big change in the database schema in 2.x series for performance and storage size reasons. In order to fully upgrade from 1.3.x you need to run schema migrations. The migrations were included in 2.0.0 release and removed in further releases. Specifically it was this one:
https://github.com/RailsEventStore/rails_event_store/blob/v2.0.0/rails_event_store_active_record/lib/rails_event_store_active_record/generators/templates/no_global_stream_entries_template.rb

The details and migration steps are described in 2.0.0 release changelog entry:
https://github.com/RailsEventStore/rails_event_store/releases/tag/v2.0.0

I'm working on upgrading a project to Ruby 3

Was there anything in RES 1.3.1 release not working on Ruby 3.0.6?

@jmkoni
Copy link
Author

jmkoni commented Jul 18, 2023

@pawelpacana Thank you! I'll try running the migrations. Re 1.3.1 & 3.0.6, iir there was another gem that forced me to update, not rails_event_store alone.

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

2 participants