ruby_event_store-active_record 2.14.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 768f44df1b698a3b20ceb63698ce08c0a33b311e8b93b44c727a3065cb8c27cb
4
- data.tar.gz: 1cdde67b7c6199bc27e305da173fc0bdb6a036e730cea0c2f1e01a2545464617
3
+ metadata.gz: f6dac3f7810ed98872452c4633ebb8bb094a4d618034dd7dda48dfe8d7ed0bd3
4
+ data.tar.gz: 662c54f97ff44e2bffee8c2a4778d9d9df41f574d7ea22c022c14c25ee5dcd77
5
5
  SHA512:
6
- metadata.gz: 1e63b20b1c818ef39e88c4ed13de111894676e9b804acea6a2442310899b6609d84e1d6e60a0aa2c1c896dcec3eb131650dea7c4b7948eafd91e4dd5c0f20516
7
- data.tar.gz: 7b774ec7afa20277cfcec9d0c4fa825fc6822c8ff037cef7c3310c512f324696e3ce80720fe95a8f959d498d60625cbb4f55bef4b0275fbdd036e3b41e081b4a
6
+ metadata.gz: ba3dc7e89badf817ad360d50337dce8fd938bb35b72ea44b3697e0c33b4fb1dfd175990d63ea0b6e742c5fe5ba7643bd2cb9bb048ffaa0aa6b3036e6609e8312
7
+ data.tar.gz: 4321bced1912ffa0f81ebdcffc972de0d969e65fddec209bdf7541ad69bb3e633555678169d1343b648da155223f87eb5eeaed49ea95d2d23a2ecb5831d34261
@@ -18,22 +18,13 @@ module RubyEventStore
18
18
  def append_to_stream(records, stream, expected_version)
19
19
  return if records.empty?
20
20
 
21
- hashes = []
22
- event_ids = []
23
- records.each do |record|
24
- hashes << insert_hash(record, record.serialize(serializer))
25
- event_ids << record.event_id
26
- end
27
- add_to_stream(event_ids, stream, expected_version) { @event_klass.insert_all!(hashes) }
21
+ append_to_stream_(records, stream, expected_version)
28
22
  end
29
23
 
30
24
  def link_to_stream(event_ids, stream, expected_version)
31
25
  return if event_ids.empty?
32
26
 
33
- (event_ids - @event_klass.where(event_id: event_ids).pluck(:event_id)).each do |id|
34
- raise EventNotFound.new(id)
35
- end
36
- add_to_stream(event_ids, stream, expected_version)
27
+ link_to_stream_(event_ids, stream, expected_version)
37
28
  end
38
29
 
39
30
  def delete_stream(stream)
@@ -159,6 +150,25 @@ module RubyEventStore
159
150
  def start_transaction(&block)
160
151
  @event_klass.transaction(requires_new: true, &block)
161
152
  end
153
+
154
+ def link_to_stream_(event_ids, stream, expected_version)
155
+ (
156
+ event_ids - @event_klass.where(event_id: event_ids).pluck(:event_id)
157
+ ).each { |id| raise EventNotFound.new(id) }
158
+ add_to_stream(event_ids, stream, expected_version)
159
+ end
160
+
161
+ def append_to_stream_(records, stream, expected_version)
162
+ hashes = []
163
+ event_ids = []
164
+ records.each do |record|
165
+ hashes << insert_hash(record, record.serialize(serializer))
166
+ event_ids << record.event_id
167
+ end
168
+ add_to_stream(event_ids, stream, expected_version) do
169
+ @event_klass.insert_all!(hashes)
170
+ end
171
+ end
162
172
  end
163
173
  end
164
174
  end
@@ -2,16 +2,6 @@
2
2
 
3
3
  class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
4
4
  def change
5
- create_table(:event_store_events_in_streams, force: false) do |t|
6
- t.string :stream, null: false
7
- t.integer :position, null: true
8
- t.references :event, null: false, type: :string, limit: 36, index: false
9
- t.datetime :created_at, null: false, precision: 6, index: true
10
- end
11
- add_index :event_store_events_in_streams, [:stream, :position], unique: true
12
- add_index :event_store_events_in_streams, [:stream, :event_id], unique: true
13
- add_index :event_store_events_in_streams, [:event_id]
14
-
15
5
  create_table(:event_store_events, force: false) do |t|
16
6
  t.references :event, null: false, type: :string, limit: 36, index: { unique: true }
17
7
  t.string :event_type, null: false, index: true
@@ -21,6 +11,14 @@ class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
21
11
  t.datetime :valid_at, null: true, precision: 6, index: true
22
12
  end
23
13
 
24
- add_foreign_key "event_store_events_in_streams", "event_store_events", column: "event_id", primary_key: "event_id"
14
+ create_table(:event_store_events_in_streams, force: false) do |t|
15
+ t.string :stream, null: false
16
+ t.integer :position, null: true, default: :null
17
+ t.references :event, null: false, type: :string, limit: 36, index: true, foreign_key: { to_table: :event_store_events, primary_key: :event_id }
18
+ t.datetime :created_at, null: false, precision: 6, index: true
19
+
20
+ t.index [:stream, :position], unique: true
21
+ t.index [:stream, :event_id], unique: true
22
+ end
25
23
  end
26
24
  end
@@ -2,16 +2,6 @@
2
2
 
3
3
  class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
4
4
  def change
5
- create_table(:event_store_events_in_streams, force: false) do |t|
6
- t.string :stream, null: false
7
- t.integer :position, null: true
8
- t.references :event, null: false, type: :string, limit: 36, index: false
9
- t.datetime :created_at, null: false, precision: 6, index: true
10
- end
11
- add_index :event_store_events_in_streams, [:stream, :position], unique: true
12
- add_index :event_store_events_in_streams, [:stream, :event_id], unique: true
13
- add_index :event_store_events_in_streams, [:event_id]
14
-
15
5
  create_table(:event_store_events, force: false) do |t|
16
6
  t.references :event, null: false, type: :string, limit: 36, index: { unique: true }
17
7
  t.string :event_type, null: false, index: true
@@ -21,6 +11,14 @@ class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
21
11
  t.datetime :valid_at, null: true, precision: 6, index: true
22
12
  end
23
13
 
24
- add_foreign_key "event_store_events_in_streams", "event_store_events", column: "event_id", primary_key: "event_id"
14
+ create_table(:event_store_events_in_streams, force: false) do |t|
15
+ t.string :stream, null: false
16
+ t.integer :position, null: true
17
+ t.references :event, null: false, type: :string, limit: 36, index: true, foreign_key: { to_table: :event_store_events, primary_key: :event_id }
18
+ t.datetime :created_at, null: false, precision: 6, index: true
19
+
20
+ t.index [:stream, :position], unique: true
21
+ t.index [:stream, :event_id], unique: true
22
+ end
25
23
  end
26
24
  end
@@ -2,16 +2,6 @@
2
2
 
3
3
  class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
4
4
  def change
5
- create_table(:event_store_events_in_streams, id: :bigserial, force: false) do |t|
6
- t.string :stream, null: false
7
- t.integer :position, null: true
8
- t.references :event, null: false, type: :uuid, index: false
9
- t.datetime :created_at, null: false, type: :timestamp, precision: 6, index: true
10
- end
11
- add_index :event_store_events_in_streams, [:stream, :position], unique: true
12
- add_index :event_store_events_in_streams, [:stream, :event_id], unique: true
13
- add_index :event_store_events_in_streams, [:event_id]
14
-
15
5
  create_table(:event_store_events, id: :bigserial, force: false) do |t|
16
6
  t.references :event, null: false, type: :uuid, index: { unique: true }
17
7
  t.string :event_type, null: false, index: true
@@ -21,6 +11,14 @@ class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
21
11
  t.datetime :valid_at, null: true, type: :timestamp, precision: 6, index: true
22
12
  end
23
13
 
24
- add_foreign_key "event_store_events_in_streams", "event_store_events", column: "event_id", primary_key: "event_id"
14
+ create_table(:event_store_events_in_streams, id: :bigserial, force: false) do |t|
15
+ t.string :stream, null: false
16
+ t.integer :position, null: true
17
+ t.references :event, null: false, type: :uuid, index: true, foreign_key: { to_table: :event_store_events, primary_key: :event_id }
18
+ t.datetime :created_at, null: false, type: :timestamp, precision: 6, index: true
19
+
20
+ t.index [:stream, :position], unique: true
21
+ t.index [:stream, :event_id], unique: true
22
+ end
25
23
  end
26
24
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyEventStore
4
4
  module ActiveRecord
5
- VERSION = "2.14.0"
5
+ VERSION = "2.15.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.0
4
+ version: 2.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-29 00:00:00.000000000 Z
11
+ date: 2024-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby_event_store
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.14.0
19
+ version: 2.15.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.14.0
26
+ version: 2.15.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 3.5.5
107
+ rubygems_version: 3.5.17
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: Persistent event repository implementation for RubyEventStore based on ActiveRecord