pg_eventstore 0.1.0 → 0.2.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: 330df61b6d77cd8211f42750b42eaef7165c66a22fc1f33a6a138248fe8beb9b
4
- data.tar.gz: 021b611a40e2392020600ad4650467e14113295bd332de5d42a16f2354e38561
3
+ metadata.gz: 4c5705fc0df6f406d7e6a0b7adbd32fa28d67197776143cd9bba4c05f9af857e
4
+ data.tar.gz: 91d7e31d70d123d1bbcb537647de5c34d055aadea257df2908ea1a775d7fa8be
5
5
  SHA512:
6
- metadata.gz: 200fd40463fe2fc715c0680dff345a333c39aa1ef280b2654df9f69973ab5c34d0698eb7d6ef473b04bd1085b0c646ca05910157e8c1f22d639bfcd30b29d3ad
7
- data.tar.gz: 1e059c402affcac9ab5666e2263c953c27bdb9648c75dfe9a16bfa942c16cbd4429e3b1bc2fc717ee8281167a241d3be89a5e67da7f93e2bf3c9ec6d82056793
6
+ metadata.gz: ecde9a1d42eae0b7ccc98a86578ec27c58caa8f2ae7e1c94905bbb832a177a91b69a26e756c95f8ce328c9c83e7a9ae482f7f4a420bec78cc1ff6be7931e0a5f
7
+ data.tar.gz: 94c4ed769261c1b22b0be3234f6e0fb29fc2a3000356c6d8b2ce4e1a877200733d206d125b0711bde6bc832a55d998f7e406af1ba2c9c2fbccf790e14e4ad795
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.2.0] - 2023-12-13
2
+
3
+ - Improve performance by reviewing indexes
4
+ - Implement migrations
5
+
6
+ Please run `rake pg_eventstore:migrate` to migrate eventstore db to actual version.
7
+
1
8
  ## [0.1.0] - 2023-12-12
2
9
 
3
10
  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
- to create necessary database objects. After this step your `pg_eventstore` is ready to use.
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_type_and_position ON public.events USING btree (type, global_position);
2
+ CREATE INDEX idx_events_global_position ON public.events USING btree (global_position);
3
+ DROP INDEX idx_events_position_and_type;
@@ -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;
@@ -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|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgEventstore
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -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.0
4
+ version: 0.2.0
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-12 00:00:00.000000000 Z
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