rails_event_store_active_record 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/rails_event_store_active_record.rb +0 -3
- data/lib/rails_event_store_active_record/event_repository.rb +3 -9
- data/lib/rails_event_store_active_record/generators/migration_generator.rb +1 -6
- data/lib/rails_event_store_active_record/version.rb +1 -1
- metadata +19 -49
- data/.mutant.yml +0 -1
- data/CHANGELOG.md +0 -75
- data/Gemfile +0 -13
- data/Gemfile.lock +0 -245
- data/Gemfile.rails_5_0 +0 -13
- data/Gemfile.rails_5_0.lock +0 -217
- data/Gemfile.rails_5_1 +0 -13
- data/Gemfile.rails_5_1.lock +0 -217
- data/Gemfile.rails_5_2 +0 -13
- data/Gemfile.rails_5_2.lock +0 -225
- data/Gemfile.rails_6_0 +0 -13
- data/Gemfile.rails_6_0.lock +0 -241
- data/Makefile +0 -21
- data/lib/rails_event_store_active_record/generators/add_valid_at_generator.rb +0 -31
- data/lib/rails_event_store_active_record/generators/created_at_precision_generator.rb +0 -31
- data/lib/rails_event_store_active_record/generators/no_global_stream_entries_generator.rb +0 -29
- data/lib/rails_event_store_active_record/generators/templates/add_valid_at_template.rb +0 -14
- data/lib/rails_event_store_active_record/generators/templates/created_at_precision_template.rb +0 -45
- data/lib/rails_event_store_active_record/generators/templates/no_global_stream_entries_template.rb +0 -59
- data/rails_event_store_active_record.gemspec +0 -30
data/Makefile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
GEM_VERSION = $(shell cat ../RES_VERSION)
|
2
|
-
GEM_NAME = rails_event_store_active_record
|
3
|
-
REQUIRE = $(GEM_NAME)
|
4
|
-
IGNORE = RailsEventStoreActiveRecord::IndexViolationDetector\#initialize \
|
5
|
-
RailsEventStoreActiveRecord::IndexViolationDetector\#detect \
|
6
|
-
RailsEventStoreActiveRecord::IndexViolationDetector\#detect_mysql \
|
7
|
-
RailsEventStoreActiveRecord::IndexViolationDetector\#detect_postgres \
|
8
|
-
RailsEventStoreActiveRecord::PgLinearizedEventRepository* \
|
9
|
-
RailsEventStoreActiveRecord::EventRepository\#update_messages \
|
10
|
-
RailsEventStoreActiveRecord::WithAbstractBaseClass\#build_event_klass \
|
11
|
-
RailsEventStoreActiveRecord::WithAbstractBaseClass\#build_stream_klass
|
12
|
-
|
13
|
-
SUBJECT ?= RailsEventStoreActiveRecord*
|
14
|
-
DATABASE_URL ?= sqlite3::memory:
|
15
|
-
|
16
|
-
include ../support/make/install.mk
|
17
|
-
include ../support/make/test.mk
|
18
|
-
include ../support/make/mutant.mk
|
19
|
-
include ../support/make/gem.mk
|
20
|
-
include ../support/make/help.mk
|
21
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rails/generators'
|
5
|
-
rescue LoadError
|
6
|
-
end
|
7
|
-
|
8
|
-
module RailsEventStoreActiveRecord
|
9
|
-
class AddValidAtGenerator < Rails::Generators::Base
|
10
|
-
source_root File.expand_path(File.join(File.dirname(__FILE__), '../generators/templates'))
|
11
|
-
|
12
|
-
def create_migration
|
13
|
-
template "add_valid_at_template.rb", "db/migrate/#{timestamp}_add_valid_at.rb"
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def rails_version
|
19
|
-
Rails::VERSION::STRING
|
20
|
-
end
|
21
|
-
|
22
|
-
def migration_version
|
23
|
-
return nil if Gem::Version.new(rails_version) < Gem::Version.new("5.0.0")
|
24
|
-
"[4.2]"
|
25
|
-
end
|
26
|
-
|
27
|
-
def timestamp
|
28
|
-
Time.now.strftime("%Y%m%d%H%M%S")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end if defined?(Rails::Generators::Base)
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rails/generators'
|
5
|
-
rescue LoadError
|
6
|
-
end
|
7
|
-
|
8
|
-
module RailsEventStoreActiveRecord
|
9
|
-
class CreatedAtPrecisionGenerator < Rails::Generators::Base
|
10
|
-
source_root File.expand_path(File.join(File.dirname(__FILE__), '../generators/templates'))
|
11
|
-
|
12
|
-
def create_migration
|
13
|
-
template "created_at_precision_template.rb", "db/migrate/#{timestamp}_created_at_precision.rb"
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def rails_version
|
19
|
-
Rails::VERSION::STRING
|
20
|
-
end
|
21
|
-
|
22
|
-
def migration_version
|
23
|
-
return nil if Gem::Version.new(rails_version) < Gem::Version.new("5.0.0")
|
24
|
-
"[4.2]"
|
25
|
-
end
|
26
|
-
|
27
|
-
def timestamp
|
28
|
-
Time.now.strftime("%Y%m%d%H%M%S")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end if defined?(Rails::Generators::Base)
|
@@ -1,29 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'rails/generators'
|
3
|
-
rescue LoadError
|
4
|
-
end
|
5
|
-
|
6
|
-
module RailsEventStoreActiveRecord
|
7
|
-
class NoGlobalStreamEntriesGenerator < Rails::Generators::Base
|
8
|
-
source_root File.expand_path(File.join(File.dirname(__FILE__), '../generators/templates'))
|
9
|
-
|
10
|
-
def create_migration
|
11
|
-
template "no_global_stream_entries_template.rb", "db/migrate/#{timestamp}_no_global_stream_entries.rb"
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def rails_version
|
17
|
-
Rails::VERSION::STRING
|
18
|
-
end
|
19
|
-
|
20
|
-
def migration_version
|
21
|
-
return nil if Gem::Version.new(rails_version) < Gem::Version.new("5.0.0")
|
22
|
-
"[4.2]"
|
23
|
-
end
|
24
|
-
|
25
|
-
def timestamp
|
26
|
-
Time.now.strftime("%Y%m%d%H%M%S")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end if defined?(Rails::Generators::Base)
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class AddValidAt < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
def change
|
5
|
-
case ActiveRecord::Base.connection.adapter_name
|
6
|
-
when "PostgreSQL"
|
7
|
-
add_column :event_store_events, :valid_at, :datetime, null: true
|
8
|
-
else
|
9
|
-
add_column :event_store_events, :valid_at, :datetime, precision: 6, null: true
|
10
|
-
end
|
11
|
-
|
12
|
-
add_index :event_store_events, :valid_at
|
13
|
-
end
|
14
|
-
end
|
data/lib/rails_event_store_active_record/generators/templates/created_at_precision_template.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreatedAtPrecision < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
def change
|
5
|
-
case ActiveRecord::Base.connection.adapter_name
|
6
|
-
when "SQLite"
|
7
|
-
rename_table :event_store_events, :old_event_store_events
|
8
|
-
create_table(:event_store_events, id: false, force: false) do |t|
|
9
|
-
t.string :id, limit: 36, primary_key: true, null: false
|
10
|
-
t.string :event_type, null: false
|
11
|
-
t.binary :metadata
|
12
|
-
t.binary :data, null: false
|
13
|
-
t.datetime :created_at, null: false, precision: 6
|
14
|
-
end
|
15
|
-
add_index :event_store_events, :created_at
|
16
|
-
add_index :event_store_events, :event_type
|
17
|
-
execute <<-SQL
|
18
|
-
INSERT INTO event_store_events(id, event_type, metadata, data, created_at)
|
19
|
-
SELECT id, event_type, metadata, data, created_at FROM old_event_store_events;
|
20
|
-
SQL
|
21
|
-
drop_table :old_event_store_events
|
22
|
-
|
23
|
-
rename_table :event_store_events_in_streams, :old_event_store_events_in_streams
|
24
|
-
create_table(:event_store_events_in_streams, force: false) do |t|
|
25
|
-
t.string :stream, null: false
|
26
|
-
t.integer :position, null: true
|
27
|
-
t.references :event, null: false, type: :string, limit: 36
|
28
|
-
t.datetime :created_at, null: false, precision: 6
|
29
|
-
end
|
30
|
-
add_index :event_store_events_in_streams, [:stream, :position], unique: true
|
31
|
-
add_index :event_store_events_in_streams, [:created_at]
|
32
|
-
add_index :event_store_events_in_streams, [:stream, :event_id], unique: true
|
33
|
-
|
34
|
-
execute <<-SQL
|
35
|
-
INSERT INTO event_store_events_in_streams(id, stream, position, event_id, created_at)
|
36
|
-
SELECT id, stream, position, event_id, created_at FROM old_event_store_events_in_streams;
|
37
|
-
SQL
|
38
|
-
drop_table :old_event_store_events_in_streams
|
39
|
-
when "PostgreSQL"
|
40
|
-
else
|
41
|
-
change_column :event_store_events, :created_at, :datetime, precision: 6
|
42
|
-
change_column :event_store_events_in_streams, :created_at, :datetime, precision: 6
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/lib/rails_event_store_active_record/generators/templates/no_global_stream_entries_template.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
class NoGlobalStreamEntries < ActiveRecord::Migration<%= migration_version %>
|
2
|
-
def change
|
3
|
-
case ActiveRecord::Base.connection.adapter_name
|
4
|
-
when "SQLite"
|
5
|
-
rename_table :event_store_events, :old_event_store_events
|
6
|
-
create_table(:event_store_events, force: false) do |t|
|
7
|
-
t.references :event, null: false, type: :string, limit: 36
|
8
|
-
t.string :event_type, null: false
|
9
|
-
t.binary :metadata
|
10
|
-
t.binary :data, null: false
|
11
|
-
t.datetime :created_at, precision: 6, null: false
|
12
|
-
t.datetime :valid_at, precision: 6, null: true
|
13
|
-
end
|
14
|
-
add_index :event_store_events, :event_id, unique: true
|
15
|
-
add_index :event_store_events, :created_at
|
16
|
-
add_index :event_store_events, :valid_at
|
17
|
-
add_index :event_store_events, :event_type
|
18
|
-
|
19
|
-
execute <<-SQL
|
20
|
-
INSERT INTO event_store_events(event_id, event_type, metadata, data, created_at)
|
21
|
-
SELECT id, event_type, metadata, data, created_at FROM old_event_store_events;
|
22
|
-
SQL
|
23
|
-
drop_table :old_event_store_events
|
24
|
-
when "PostgreSQL"
|
25
|
-
rename_column :event_store_events, :id, :event_id
|
26
|
-
change_column_default :event_store_events, :event_id, nil
|
27
|
-
add_column :event_store_events, :id, :serial
|
28
|
-
|
29
|
-
execute <<~SQL
|
30
|
-
UPDATE event_store_events
|
31
|
-
SET id = event_store_events_in_streams.id
|
32
|
-
FROM event_store_events_in_streams
|
33
|
-
WHERE event_store_events.event_id = event_store_events_in_streams.event_id AND event_store_events_in_streams.stream = 'all';
|
34
|
-
UPDATE event_store_events
|
35
|
-
SET id = ese.new_id
|
36
|
-
FROM (SELECT id, row_number() OVER (ORDER BY id) AS new_id FROM event_store_events) ese
|
37
|
-
WHERE event_store_events.id = ese.id;
|
38
|
-
SELECT setval(pg_get_serial_sequence('event_store_events', 'id'), max(id)) FROM event_store_events;
|
39
|
-
ALTER TABLE event_store_events DROP CONSTRAINT event_store_events_pkey;
|
40
|
-
ALTER TABLE event_store_events ADD PRIMARY KEY (id);
|
41
|
-
SQL
|
42
|
-
add_index :event_store_events, :event_id, unique: true
|
43
|
-
else
|
44
|
-
rename_column :event_store_events, :id, :event_id
|
45
|
-
add_column :event_store_events, :id, :integer
|
46
|
-
|
47
|
-
execute <<-SQL
|
48
|
-
UPDATE event_store_events
|
49
|
-
INNER JOIN event_store_events_in_streams ON (event_store_events.event_id = event_store_events_in_streams.event_id)
|
50
|
-
SET event_store_events.id = event_store_events_in_streams.id
|
51
|
-
WHERE event_store_events_in_streams.stream = 'all';
|
52
|
-
SQL
|
53
|
-
execute "SET @row_number = 0"
|
54
|
-
execute "UPDATE event_store_events SET event_store_events.id = (@row_number:=@row_number + 1) ORDER BY id"
|
55
|
-
execute "ALTER TABLE event_store_events DROP PRIMARY KEY, ADD PRIMARY KEY (id), MODIFY id INT AUTO_INCREMENT"
|
56
|
-
add_index :event_store_events, :event_id, unique: true
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'rails_event_store_active_record/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'rails_event_store_active_record'
|
8
|
-
spec.version = RailsEventStoreActiveRecord::VERSION
|
9
|
-
spec.licenses = ['MIT']
|
10
|
-
spec.authors = ['Arkency']
|
11
|
-
spec.email = ['dev@arkency.com']
|
12
|
-
|
13
|
-
spec.summary = %q{Active Record events repository for Rails Event Store}
|
14
|
-
spec.description = %q{Implementation of events repository based on Rails Active Record for Rails Event Store}
|
15
|
-
spec.homepage = 'https://railseventstore.org'
|
16
|
-
spec.metadata = {
|
17
|
-
"homepage_uri" => "https://railseventstore.org/",
|
18
|
-
"changelog_uri" => "https://github.com/RailsEventStore/rails_event_store/releases",
|
19
|
-
"source_code_uri" => "https://github.com/RailsEventStore/rails_event_store",
|
20
|
-
"bug_tracker_uri" => "https://github.com/RailsEventStore/rails_event_store/issues",
|
21
|
-
}
|
22
|
-
|
23
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
-
spec.require_paths = ['lib']
|
25
|
-
|
26
|
-
spec.add_dependency 'ruby_event_store', '= 2.0.1'
|
27
|
-
spec.add_dependency 'activesupport', '>= 3.0'
|
28
|
-
spec.add_dependency 'activemodel', '>= 3.0'
|
29
|
-
spec.add_dependency 'activerecord-import', '>= 1.0.2'
|
30
|
-
end
|