pg_eventstore 0.1.0 → 0.2.0
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 +4 -4
- data/CHANGELOG.md +7 -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/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: 4c5705fc0df6f406d7e6a0b7adbd32fa28d67197776143cd9bba4c05f9af857e
|
4
|
+
data.tar.gz: 91d7e31d70d123d1bbcb537647de5c34d055aadea257df2908ea1a775d7fa8be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecde9a1d42eae0b7ccc98a86578ec27c58caa8f2ae7e1c94905bbb832a177a91b69a26e756c95f8ce328c9c83e7a9ae482f7f4a420bec78cc1ff6be7931e0a5f
|
7
|
+
data.tar.gz: 94c4ed769261c1b22b0be3234f6e0fb29fc2a3000356c6d8b2ce4e1a877200733d206d125b0711bde6bc832a55d998f7e406af1ba2c9c2fbccf790e14e4ad795
|
data/CHANGELOG.md
CHANGED
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;
|
@@ -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.
|
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-
|
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
|