ruby_event_store-active_record 2.19.0 → 2.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e59b38492f8cd12d3131547e67dacc272ef2dd0e6df85934fabdf115ea9489f
4
- data.tar.gz: 63e1cefc86fb9e06396ea293edc9e52e1b3ef6cc161a25cf90f3a5fd6c07f3af
3
+ metadata.gz: 3104c766e190c7e815b05ef7e2c528e6ed96bbaece55d9c2f4ee1f344aa94116
4
+ data.tar.gz: 498edf27aee7ef801582b46f4d513c731536435cea58354cef1e35d7b538c9f5
5
5
  SHA512:
6
- metadata.gz: ca70c4f361e079a0ce1734a5acc246524a2b619f910a3fcacabe3beeb1bbc44b8bdf49c87b3c70ae68818e3eb569687180f24b6f7b6d8938de8843372a981473
7
- data.tar.gz: 7691d7f87960edf26d4c5ef89087ae6faef317cd0f12455fd9fbd6cbdd3ab4fb6c1126cedd981846d33aa3c88a9ff432e6da13b19a46de7ee4846f49487aa631
6
+ metadata.gz: 303f1dcd86e4241ab9a511c21c7ce5e336ad939695d2c69d9693d5e9ab2bc042cc1e16dbf6f17ccaf1cce3e502709925c8c72609e22f16e2bcbf7d51db549105
7
+ data.tar.gz: 4e3dc13667f3fa3bd1b58d90e10675b2516d22408c92cc593e5be1816102adcfcb2eee7a0c08fd7494f4825bd97140d27b9f8095979084576c9c5314e27d3f04
@@ -34,8 +34,7 @@ module RubyEventStore
34
34
  end
35
35
 
36
36
  def count(spec)
37
- scope_size = read_scope(spec).count # mutant:disable
38
- scope_size
37
+ read_scope(spec).count # mutant:disable
39
38
  end
40
39
 
41
40
  def streams_of(event_id)
@@ -4,11 +4,15 @@ module RubyEventStore
4
4
  module ActiveRecord
5
5
  class EventIdIndexMigrationGenerator
6
6
  def call(migration_path)
7
- path = build_path(migration_path)
8
- write_to_file(path)
7
+ path, content = generate(migration_path)
8
+ File.write(path, content)
9
9
  path
10
10
  end
11
11
 
12
+ def generate(migration_path)
13
+ [build_path(migration_path), migration_code]
14
+ end
15
+
12
16
  private
13
17
 
14
18
  def absolute_path(path)
@@ -35,10 +39,6 @@ module RubyEventStore
35
39
  Time.now.strftime("%Y%m%d%H%M%S")
36
40
  end
37
41
 
38
- def write_to_file(path)
39
- File.write(path, migration_code)
40
- end
41
-
42
42
  def build_path(migration_path)
43
43
  File.join("#{migration_path}", "#{timestamp}_add_event_id_index_to_event_store_events_in_streams.rb")
44
44
  end
@@ -4,16 +4,24 @@ module RubyEventStore
4
4
  module ActiveRecord
5
5
  class ForeignKeyOnEventIdMigrationGenerator
6
6
  def call(database_adapter, migration_path)
7
+ generate(database_adapter, migration_path).each do |path, content|
8
+ File.write(path, content)
9
+ end
10
+ end
11
+
12
+ def generate(database_adapter, migration_path)
7
13
  time = Time.now
8
- each_migration(database_adapter) do |migration_name, i|
9
- path = build_path(migration_path, migration_name, time + i)
10
- write_to_file(path, migration_code(database_adapter, migration_name))
14
+ migration_names(database_adapter).map.with_index do |migration_name, i|
15
+ [
16
+ build_path(migration_path, migration_name, time + i),
17
+ migration_code(database_adapter, migration_name),
18
+ ]
11
19
  end
12
20
  end
13
21
 
14
22
  private
15
23
 
16
- def each_migration(database_adapter, &block)
24
+ def migration_names(database_adapter)
17
25
  case database_adapter
18
26
  when DatabaseAdapter::PostgreSQL
19
27
  %w[
@@ -22,7 +30,7 @@ module RubyEventStore
22
30
  ]
23
31
  else
24
32
  ["add_foreign_key_on_event_id_to_event_store_events_in_streams"]
25
- end.each.with_index(&block)
33
+ end
26
34
  end
27
35
 
28
36
  def absolute_path(path)
@@ -47,10 +55,6 @@ module RubyEventStore
47
55
  ::ActiveRecord::Migration.current_version
48
56
  end
49
57
 
50
- def write_to_file(path, migration_code)
51
- File.write(path, migration_code)
52
- end
53
-
54
58
  def build_path(migration_path, migration_name, time)
55
59
  File.join("#{migration_path}", "#{migration_verion_number(time)}_#{migration_name}.rb")
56
60
  end
@@ -6,12 +6,15 @@ module RubyEventStore
6
6
  module ActiveRecord
7
7
  class MigrationGenerator
8
8
  def call(database_adapter, migration_path)
9
- migration_code = migration_code(database_adapter)
10
- path = build_path(migration_path)
11
- write_to_file(migration_code, path)
9
+ path, content = generate(database_adapter, migration_path)
10
+ File.write(path, content)
12
11
  path
13
12
  end
14
13
 
14
+ def generate(database_adapter, migration_path)
15
+ [build_path(migration_path), migration_code(database_adapter)]
16
+ end
17
+
15
18
  private
16
19
 
17
20
  def absolute_path(path)
@@ -41,10 +44,6 @@ module RubyEventStore
41
44
  Time.now.strftime("%Y%m%d%H%M%S")
42
45
  end
43
46
 
44
- def write_to_file(migration_code, path)
45
- File.write(path, migration_code)
46
- end
47
-
48
47
  def build_path(migration_path)
49
48
  File.join("#{migration_path}", "#{timestamp}_create_event_store_events.rb")
50
49
  end
@@ -1,9 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class AddValidAtIndexToEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
4
- def change
5
- return if index_exists?(:event_store_events, nil, name: "index_event_store_events_on_as_of")
4
+ disable_ddl_transaction!
6
5
 
7
- add_index :event_store_events, "COALESCE(valid_at, created_at)", name: "index_event_store_events_on_as_of"
6
+ def change
7
+ unless index_exists?(:event_store_events, "COALESCE(valid_at, created_at)",
8
+ name: "index_event_store_events_on_as_of")
9
+ add_index :event_store_events,
10
+ "COALESCE(valid_at, created_at)",
11
+ name: "index_event_store_events_on_as_of",
12
+ algorithm: :concurrently
13
+ end
8
14
  end
9
15
  end
@@ -4,11 +4,15 @@ module RubyEventStore
4
4
  module ActiveRecord
5
5
  class ValidAtIndexMigrationGenerator
6
6
  def call(migration_path)
7
- path = build_path(migration_path)
8
- write_to_file(path)
7
+ path, content = generate(migration_path)
8
+ File.write(path, content)
9
9
  path
10
10
  end
11
11
 
12
+ def generate(migration_path)
13
+ [build_path(migration_path), migration_code]
14
+ end
15
+
12
16
  private
13
17
 
14
18
  def absolute_path(path)
@@ -35,10 +39,6 @@ module RubyEventStore
35
39
  Time.now.strftime("%Y%m%d%H%M%S")
36
40
  end
37
41
 
38
- def write_to_file(path)
39
- File.write(path, migration_code)
40
- end
41
-
42
42
  def build_path(migration_path)
43
43
  File.join("#{migration_path}", "#{timestamp}_add_valid_at_index_to_event_store_events.rb")
44
44
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyEventStore
4
4
  module ActiveRecord
5
- VERSION = "2.19.0"
5
+ VERSION = "2.19.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.19.0
4
+ version: 2.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 2.19.0
18
+ version: 2.19.1
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 2.19.0
25
+ version: 2.19.1
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activerecord
28
28
  requirement: !ruby/object:Gem::Requirement