pg_eventstore 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +4 -1
- data/db/migrations/0_improve_all_stream_indexes.sql +3 -0
- data/db/migrations/1_improve_specific_stream_indexes.sql +3 -0
- data/lib/pg_eventstore/queries.rb +1 -1
- data/lib/pg_eventstore/tasks/setup.rake +25 -1
- data/lib/pg_eventstore/version.rb +1 -1
- data/pg_eventstore.gemspec +1 -1
- metadata +8 -6
- /data/db/{extensions.sql → initial/extensions.sql} +0 -0
- /data/db/{indexes.sql → initial/indexes.sql} +0 -0
- /data/db/{primary_and_foreign_keys.sql → initial/primary_and_foreign_keys.sql} +0 -0
- /data/db/{tables.sql → initial/tables.sql} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8d3f73730a86f5a8d8849da2faa8c2e24a937e5d062b51928ae3f4034030f54
|
4
|
+
data.tar.gz: 47c6381424341a8b5b86e7dd8e66c0f090d8485755b6e7fc79a9d5e33c5cbde1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc542c87250be7e2c840ae526cca7dcd9dee55bf7069572b7fc669564c4173a0ec4334a5714dfb92f874cf8717a087ba474ae4aa7697c36dc541883346a12383
|
7
|
+
data.tar.gz: deedd9c173935973dc7330365acd21e4125d5abb9e23975af3a19fc1c6549c3a9944ae0420753034af5d5ed7b60c793d90e90ced0b866ec410a42cc6306400dc
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## [0.2.1] - 2023-12-13
|
2
|
+
|
3
|
+
Under certain circumstances `PG::TRSerializationFailure` exception wasn't retried. Adjust connection's states list to fix that.
|
4
|
+
|
5
|
+
## [0.2.0] - 2023-12-13
|
6
|
+
|
7
|
+
- Improve performance by reviewing indexes
|
8
|
+
- Implement migrations
|
9
|
+
|
10
|
+
Please run `rake pg_eventstore:migrate` to migrate eventstore db to actual version.
|
11
|
+
|
1
12
|
## [0.1.0] - 2023-12-12
|
2
13
|
|
3
14
|
Initial release.
|
data/README.md
CHANGED
@@ -39,9 +39,12 @@ load "pg_eventstore/tasks/setup.rake"
|
|
39
39
|
|
40
40
|
This will include necessary rake tasks. You can now run
|
41
41
|
```bash
|
42
|
+
export PG_EVENTSTORE_URI="postgresql://postgres:postgres@localhost:5532/postgres" # Replace this with your real connection url
|
42
43
|
bundle exec rake pg_eventstore:create
|
44
|
+
bundle exec rake pg_eventstore:migrate
|
43
45
|
```
|
44
|
-
|
46
|
+
|
47
|
+
to create necessary database objects and migrate them to the actual version. After this step your `pg_eventstore` is ready to use.
|
45
48
|
|
46
49
|
Documentation chapters:
|
47
50
|
|
@@ -0,0 +1,3 @@
|
|
1
|
+
CREATE INDEX idx_events_stream_id_and_type_and_revision ON public.events USING btree (stream_id, type, stream_revision);
|
2
|
+
CREATE INDEX idx_events_stream_id_and_revision ON public.events USING btree (stream_id, stream_revision);
|
3
|
+
DROP INDEX idx_events_stream_id_and_revision_and_type;
|
@@ -31,7 +31,7 @@ module PgEventstore
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
rescue PG::TRSerializationFailure, PG::TRDeadlockDetected => e
|
34
|
-
retry if e.connection.transaction_status
|
34
|
+
retry if [PG::PQTRANS_IDLE, PG::PQTRANS_UNKNOWN].include?(e.connection.transaction_status)
|
35
35
|
raise
|
36
36
|
end
|
37
37
|
|
@@ -7,7 +7,7 @@ namespace :pg_eventstore do
|
|
7
7
|
config.pg_uri = ENV['PG_EVENTSTORE_URI']
|
8
8
|
end
|
9
9
|
|
10
|
-
db_files_root = "#{Gem::Specification.find_by_name("pg_eventstore").gem_dir}/db"
|
10
|
+
db_files_root = "#{Gem::Specification.find_by_name("pg_eventstore").gem_dir}/db/initial"
|
11
11
|
|
12
12
|
PgEventstore.connection.with do |conn|
|
13
13
|
conn.transaction do
|
@@ -19,6 +19,30 @@ namespace :pg_eventstore do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
task :migrate do
|
23
|
+
PgEventstore.configure do |config|
|
24
|
+
config.pg_uri = ENV['PG_EVENTSTORE_URI']
|
25
|
+
end
|
26
|
+
|
27
|
+
migration_files_root = "#{Gem::Specification.find_by_name("pg_eventstore").gem_dir}/db/migrations"
|
28
|
+
|
29
|
+
PgEventstore.connection.with do |conn|
|
30
|
+
conn.exec('CREATE TABLE IF NOT EXISTS migrations (number int NOT NULL)')
|
31
|
+
latest_migration =
|
32
|
+
conn.exec('SELECT number FROM migrations ORDER BY number DESC LIMIT 1').to_a.dig(0, 'number') || -1
|
33
|
+
|
34
|
+
Dir["#{migration_files_root}/*.sql"].each do |f_name|
|
35
|
+
number = File.basename(f_name).split('_')[0].to_i
|
36
|
+
next if latest_migration >= number
|
37
|
+
|
38
|
+
conn.transaction do
|
39
|
+
conn.exec(File.read(f_name))
|
40
|
+
conn.exec_params('INSERT INTO migrations (number) VALUES ($1)', [number])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
22
46
|
desc "Drops events table and related pg_eventstore objects."
|
23
47
|
task :drop do
|
24
48
|
PgEventstore.configure do |config|
|
data/pg_eventstore.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.files = Dir.chdir(__dir__) do
|
26
26
|
paths_to_exclude = %w[
|
27
27
|
bin/ test/ spec/ features/ .git .circleci appveyor Gemfile .ruby-version .ruby-gemset .rspec docker-compose.yml
|
28
|
-
Rakefile benchmark/ .yardopts
|
28
|
+
Rakefile benchmark/ .yardopts db/structure.sql
|
29
29
|
]
|
30
30
|
`git ls-files -z`.split("\x0").reject do |f|
|
31
31
|
(File.expand_path(f) == __FILE__) || f.start_with?(*paths_to_exclude)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_eventstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Dzyzenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -49,10 +49,12 @@ files:
|
|
49
49
|
- CODE_OF_CONDUCT.md
|
50
50
|
- LICENSE.txt
|
51
51
|
- README.md
|
52
|
-
- db/extensions.sql
|
53
|
-
- db/indexes.sql
|
54
|
-
- db/primary_and_foreign_keys.sql
|
55
|
-
- db/tables.sql
|
52
|
+
- db/initial/extensions.sql
|
53
|
+
- db/initial/indexes.sql
|
54
|
+
- db/initial/primary_and_foreign_keys.sql
|
55
|
+
- db/initial/tables.sql
|
56
|
+
- db/migrations/0_improve_all_stream_indexes.sql
|
57
|
+
- db/migrations/1_improve_specific_stream_indexes.sql
|
56
58
|
- docs/appending_events.md
|
57
59
|
- docs/configuration.md
|
58
60
|
- docs/events_and_streams.md
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|