sequent 8.1.0 → 8.1.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: 5e7ff410ea483cffeb038904103ecad45b89c7f9907775362a18daf2a9a0a7e5
4
- data.tar.gz: bcb33c8793653e31677e5883195dc0babc57c7259c8e4e76e7491f91272ee65f
3
+ metadata.gz: 2c1c844dd60b40d09f71df31af4ed2082af51665e5a652128dd1ba7e53473535
4
+ data.tar.gz: 1597ad4e428b852a0f720bfcb05c79a5734e72e81a2302feacc870adeb4eb738
5
5
  SHA512:
6
- metadata.gz: f5acb72e36e29fcf811734b8db7ee49b7a2e2cc915fafcc675636bfcd399e8961cf514c40d8312d59ea6c289379160ac3fd8f04f45c1cba7f529e6806ca3b415
7
- data.tar.gz: 93fa973ab3fc2454bc49b2359e254733b9ca7a850f4c30b31a08a7d14b9cd7d72889d3386e1946bc85d18c16c4f5a326fa2198f7e5b6005e0eb55f320bdf993b
6
+ metadata.gz: 44929e619dc88180add807b71794d8520b6f0f33af7a379cad7a3bc2b73ecd2a83ce028df51bf89d6278a615011d0a100f8fe48ac1d44ef23b4d859af24621f1
7
+ data.tar.gz: 0b983b286c48a2037f31c13cb229769fe2216a4d011fe711a249f5502260f47612eee3b744943abf50a413135b4bd5532f55b1d3c0221d4ebf2df188d16a5f61
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AggregateUniqueKeys < ActiveRecord::Migration[7.2]
4
+ def up
5
+ Sequent::Support::Database.with_search_path(Sequent.configuration.event_store_schema_name) do
6
+ say 'Creating aggregate_unique_keys table', true
7
+ suppress_messages do
8
+ execute <<~SQL
9
+ CREATE TABLE IF NOT EXISTS aggregate_unique_keys (
10
+ aggregate_id uuid NOT NULL,
11
+ scope text NOT NULL,
12
+ key jsonb NOT NULL,
13
+ PRIMARY KEY (aggregate_id, scope),
14
+ UNIQUE (scope, key),
15
+ FOREIGN KEY (aggregate_id) REFERENCES aggregates (aggregate_id) ON UPDATE CASCADE ON DELETE CASCADE
16
+ )
17
+ SQL
18
+ end
19
+
20
+ say 'Creating event store stored procedures and views', true
21
+ suppress_messages do
22
+ sequent_pgsql_filename = File.join(Sequent.configuration.database_schema_directory, 'sequent_pgsql.sql')
23
+ execute File.read(sequent_pgsql_filename)
24
+ end
25
+ end
26
+ end
27
+
28
+ def down
29
+ fail ActiveRecord::IrreversibleMigration
30
+ end
31
+ end
@@ -1,6 +1,6 @@
1
- CREATE TABLE command_types (id SMALLINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, type text UNIQUE NOT NULL);
2
- CREATE TABLE aggregate_types (id SMALLINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, type text UNIQUE NOT NULL);
3
- CREATE TABLE event_types (id SMALLINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, type text UNIQUE NOT NULL);
1
+ CREATE TABLE command_types (id SMALLINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, type text UNIQUE NOT NULL);
2
+ CREATE TABLE aggregate_types (id SMALLINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, type text UNIQUE NOT NULL);
3
+ CREATE TABLE event_types (id SMALLINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, type text UNIQUE NOT NULL);
4
4
 
5
5
  CREATE SEQUENCE IF NOT EXISTS commands_id_seq;
6
6
 
@@ -83,11 +83,6 @@ module Sequent
83
83
 
84
84
  disconnect!
85
85
 
86
- if ActiveRecord::VERSION::MAJOR < 6
87
- ActiveRecord::Base.configurations[env.to_s] =
88
- ActiveSupport::HashWithIndifferentAccess.new(db_config).stringify_keys
89
- end
90
-
91
86
  establish_connection(db_config, {schema_search_path: search_path})
92
87
  yield
93
88
  ensure
@@ -95,6 +90,16 @@ module Sequent
95
90
  establish_connection(db_config)
96
91
  end
97
92
 
93
+ def self.with_search_path(search_path)
94
+ old_search_path = ActiveRecord::Base.connection.select_value("SELECT current_setting('search_path')")
95
+ begin
96
+ ActiveRecord::Base.connection.exec_update("SET search_path TO #{search_path}", 'with_search_path')
97
+ yield
98
+ ensure
99
+ ActiveRecord::Base.connection.exec_update("SET search_path TO #{old_search_path}", 'with_search_path')
100
+ end
101
+ end
102
+
98
103
  def self.schema_exists?(schema, event_records_table = nil)
99
104
  schema_exists = ActiveRecord::Base.connection.exec_query(
100
105
  'SELECT 1 FROM information_schema.schemata WHERE schema_name LIKE $1',
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../test/command_handler_helpers'
4
-
5
3
  module Sequent
6
4
  module Util
7
5
  ##
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sequent
4
- VERSION = '8.1.0'
4
+ VERSION = '8.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequent
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.0
4
+ version: 8.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Vonk
@@ -369,6 +369,7 @@ extensions: []
369
369
  extra_rdoc_files: []
370
370
  files:
371
371
  - bin/sequent
372
+ - db/migrate/20250108162754_aggregate_unique_keys.rb
372
373
  - db/sequent_8_migration.sql
373
374
  - db/sequent_pgsql.sql
374
375
  - db/sequent_schema.rb