message-db 1.0.0 → 2.0.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: 933944df84aeb9ae8e8a0d265b7ef3b95a82df0d58eceed0ca31507f96f04299
4
- data.tar.gz: 307379e48df23685b9ad494315568f152b57a3481b8f17a1dcf128fabefded9c
3
+ metadata.gz: 1a5cb7492519fb76355201fb499ef7133d1e097af688752f4cff51505bc51e05
4
+ data.tar.gz: 744a8c922d0e2aeb41f5312003c7f905207308dbc771c1d40b4f7ff35dfa8117
5
5
  SHA512:
6
- metadata.gz: e730605cb9dbad8cf9072df8ec1fde409edaa6765e852893117a0a99e60bd387f94a0dbd6ffc895ca69ab3180d7b4217a2858ac640b6e272dc94038510ebf2be
7
- data.tar.gz: 664e88ea262afa6f2771563b0926fc406e3585c2a112534ba80270de13a55de5816b437217ed21265308a517fc45989994dfa2b54945b1472c204aeb47b5e326
6
+ metadata.gz: '044912f18717a75c4276231773bbcd17d5ffe6ce82c571ee96e2f0affab918cc4e026919f10b8155f7efe94f8bd198e7efe72d06599f076b8cf5fc8bb18600ad'
7
+ data.tar.gz: fb2724e33cdf5d203b3f097fdb955fb909fc1e87ea6930a778c84e5b7ee579eebf1df83c9eb83d4c9cdb4a9e860e28b65c7df051b80252bd2b5b349efe6479b3
data/database/VERSION.txt CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.4
@@ -1 +1 @@
1
- CREATE EXTENSION IF NOT EXISTS pgcrypto SCHEMA message_store;
1
+ CREATE EXTENSION IF NOT EXISTS pgcrypto;
@@ -2,7 +2,7 @@ CREATE OR REPLACE FUNCTION message_store.message_store_version()
2
2
  RETURNS varchar
3
3
  AS $$
4
4
  BEGIN
5
- RETURN '1.0.0';
5
+ RETURN '1.1.4';
6
6
  END;
7
7
  $$ LANGUAGE plpgsql
8
8
  VOLATILE;
@@ -12,8 +12,6 @@ DECLARE
12
12
  _message_id uuid;
13
13
  _stream_version bigint;
14
14
  _next_position bigint;
15
- _category varchar;
16
- _category_name_hash bigint;
17
15
  BEGIN
18
16
  PERFORM acquire_lock(write_message.stream_name);
19
17
 
@@ -65,8 +63,6 @@ BEGIN
65
63
  RAISE NOTICE 'data ($4): %', write_message.data;
66
64
  RAISE NOTICE 'metadata ($5): %', write_message.metadata;
67
65
  RAISE NOTICE 'expected_version ($6): %', write_message.expected_version;
68
- RAISE NOTICE '_category: %', _category;
69
- RAISE NOTICE '_category_name_hash: %', _category_name_hash;
70
66
  RAISE NOTICE '_stream_version: %', _stream_version;
71
67
  RAISE NOTICE '_next_position: %', _next_position;
72
68
  END IF;
@@ -17,6 +17,9 @@ function grant-privileges {
17
17
 
18
18
  base=$(script_dir)
19
19
 
20
+ echo "» schema privileges"
21
+ psql $database -q -f $base/privileges/schema.sql
22
+
20
23
  echo "» messages table privileges"
21
24
  psql $database -q -f $base/privileges/table.sql
22
25
 
@@ -1,14 +1,15 @@
1
+ GRANT EXECUTE ON FUNCTION gen_random_uuid() TO message_store;
2
+ GRANT EXECUTE ON FUNCTION md5(text) TO message_store;
3
+
1
4
  GRANT EXECUTE ON FUNCTION message_store.acquire_lock(varchar) TO message_store;
2
5
  GRANT EXECUTE ON FUNCTION message_store.cardinal_id(varchar) TO message_store;
3
6
  GRANT EXECUTE ON FUNCTION message_store.category(varchar) TO message_store;
4
- GRANT EXECUTE ON FUNCTION message_store.gen_random_uuid() TO message_store;
5
7
  GRANT EXECUTE ON FUNCTION message_store.get_category_messages(varchar, bigint, bigint, varchar, bigint, bigint, varchar) TO message_store;
6
8
  GRANT EXECUTE ON FUNCTION message_store.get_last_stream_message(varchar) TO message_store;
7
9
  GRANT EXECUTE ON FUNCTION message_store.get_stream_messages(varchar, bigint, bigint, varchar) TO message_store;
8
10
  GRANT EXECUTE ON FUNCTION message_store.hash_64(varchar) TO message_store;
9
11
  GRANT EXECUTE ON FUNCTION message_store.id(varchar) TO message_store;
10
12
  GRANT EXECUTE ON FUNCTION message_store.is_category(varchar) TO message_store;
11
- GRANT EXECUTE ON FUNCTION md5(text) TO message_store;
12
13
  GRANT EXECUTE ON FUNCTION message_store.message_store_version() TO message_store;
13
14
  GRANT EXECUTE ON FUNCTION message_store.stream_version(varchar) TO message_store;
14
15
  GRANT EXECUTE ON FUNCTION message_store.write_message(varchar, varchar, varchar, jsonb, jsonb, bigint) TO message_store;
@@ -0,0 +1 @@
1
+ GRANT USAGE ON SCHEMA message_store TO message_store;
@@ -1 +1 @@
1
- CREATE SCHEMA IF NOT EXISTS message_store AUTHORIZATION message_store;
1
+ CREATE SCHEMA IF NOT EXISTS message_store;
@@ -1,5 +1,5 @@
1
1
  CREATE TABLE IF NOT EXISTS message_store.messages (
2
- id UUID NOT NULL DEFAULT message_store.gen_random_uuid(),
2
+ id UUID NOT NULL DEFAULT gen_random_uuid(),
3
3
  stream_name text NOT NULL,
4
4
  type text NOT NULL,
5
5
  position bigint NOT NULL,
data/database/update.sh CHANGED
@@ -2,170 +2,17 @@
2
2
 
3
3
  set -e
4
4
 
5
- function script_dir {
6
- val="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7
- echo "$val"
8
- }
9
-
10
- base=$(script_dir)
11
-
12
- echo
13
- echo "Updating Database"
14
- echo "Version: $(cat $base/VERSION.txt)"
15
- echo "= = ="
16
-
17
- if [ -z ${DATABASE_NAME+x} ]; then
18
- echo "(DATABASE_NAME is not set. Default will be used.)"
19
- database=message_store
20
- export DATABASE_NAME=$database
21
- else
22
- database=$DATABASE_NAME
23
- fi
24
- echo
25
-
26
- if [ -z ${PGOPTIONS+x} ]; then
27
- export PGOPTIONS='-c client_min_messages=warning'
28
- fi
29
-
30
- function delete-extensions {
31
- echo "» pgcrypto extension"
32
- psql $database -q -c "DROP EXTENSION IF EXISTS pgcrypto";
33
- }
34
-
35
- function delete-indexes {
36
- echo "» messages_id_uniq_idx index"
37
- psql $database -q -c "DROP INDEX IF EXISTS messages_id_uniq_idx CASCADE";
38
-
39
- echo "» messages_stream_name_position_uniq_idx index"
40
- psql $database -q -c "DROP INDEX IF EXISTS messages_stream_name_position_uniq_idx";
41
-
42
- echo "» messages_category_global_position_idx index"
43
- psql $database -q -c "DROP INDEX IF EXISTS messages_category_global_position_idx";
44
- }
45
-
46
- function delete-views {
47
- echo "» stream_summary view"
48
- psql $database -q -c "DROP VIEW IF EXISTS stream_summary CASCADE";
49
-
50
- echo "» type_summary view"
51
- psql $database -q -c "DROP VIEW IF EXISTS type_summary CASCADE";
52
-
53
- echo "» stream_type_summary view"
54
- psql $database -q -c "DROP VIEW IF EXISTS stream_type_summary CASCADE";
55
-
56
- echo "» type_stream_summary view"
57
- psql $database -q -c "DROP VIEW IF EXISTS type_stream_summary CASCADE";
58
-
59
- echo "» category_type_summary view"
60
- psql $database -q -c "DROP VIEW IF EXISTS category_type_summary CASCADE";
61
-
62
- echo "» type_category_summary view"
63
- psql $database -q -c "DROP VIEW IF EXISTS type_category_summary CASCADE";
64
- }
65
-
66
- function delete-functions {
67
- echo "» hash_64 function"
68
- psql $database -q -c "DROP FUNCTION IF EXISTS hash_64 CASCADE";
69
-
70
- echo "» category function"
71
- psql $database -q -c "DROP FUNCTION IF EXISTS category CASCADE";
72
-
73
- echo "» stream_version function"
74
- psql $database -q -c "DROP FUNCTION IF EXISTS stream_version CASCADE";
75
-
76
- echo "» write_message function"
77
- psql $database -q -c "DROP FUNCTION IF EXISTS write_message CASCADE";
78
-
79
- echo "» get_stream_messages function"
80
- psql $database -q -c "DROP FUNCTION IF EXISTS get_stream_messages CASCADE";
81
-
82
- echo "» get_category_messages function"
83
- psql $database -q -c "DROP FUNCTION IF EXISTS get_category_messages CASCADE";
84
-
85
- echo "» get_last_message function"
86
- psql $database -q -c "DROP FUNCTION IF EXISTS get_last_message CASCADE";
87
- }
88
-
89
- function delete-extensions {
90
- echo "» pgcrypto extension"
91
- psql $database -q -c "DROP EXTENSION IF EXISTS pgcrypto CASCADE";
92
- }
93
-
94
- function create-schema {
95
- echo "» message_store schema"
96
- psql $database -q -f $base/schema/message-store.sql
97
- }
98
-
99
- function add-table-to-schema {
100
- echo "» messages table"
101
- psql $database -q -c "ALTER TABLE messages SET SCHEMA message_store";
102
- }
103
-
104
- function create-extensions {
105
- base=$(script_dir)
106
-
107
- echo "» pgcrypto extension"
108
- psql $database -q -f $base/extensions/pgcrypto.sql
109
- }
110
-
111
- function set-default-value {
112
- echo "» id column"
113
- psql $database -q -c "ALTER TABLE message_store.messages ALTER COLUMN id SET DEFAULT message_store.gen_random_uuid()";
114
- }
115
-
116
- echo "Deleting Views"
117
- echo "- - -"
118
- delete-views
119
- echo
120
-
121
- echo "Deleting Indexes"
122
- echo "- - -"
123
- delete-indexes
124
- echo
125
-
126
- echo "Deleting Functions"
127
- echo "- - -"
128
- delete-functions
129
- echo
130
-
131
- echo "Deleting Extensions"
132
- echo "- - -"
133
- delete-extensions
134
5
  echo
135
-
136
- echo "Creating Schema"
137
- echo "- - -"
138
- create-schema
6
+ echo "WARNING: OBSOLETE"
139
7
  echo
140
-
141
- echo "Creating Extensions"
142
- echo "- - -"
143
- create-extensions
8
+ echo "The ${BASH_SOURCE[0]} has been deprecated"
9
+ echo "See the database/update directory for current update scripts"
144
10
  echo
145
11
 
146
- echo "Adding Table to Schema"
147
- echo "- - -"
148
- add-table-to-schema
149
- echo
150
-
151
- echo "Set Default Value for ID Column"
152
- echo "- - -"
153
- set-default-value
154
- echo
155
-
156
- # Install functions
157
- source $base/install-functions.sh
158
-
159
- # Install indexes
160
- source $base/install-indexes.sh
161
-
162
- # Install views
163
- source $base/install-views.sh
12
+ current_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
13
+ update_directory="$current_directory/update"
164
14
 
165
- # Install privileges
166
- source $base/install-privileges.sh
15
+ echo "Contents of $update_directory"
16
+ ls -1 $update_directory
167
17
 
168
- echo "= = ="
169
- echo "Done Updating Database"
170
- echo "Version: $(cat $base/VERSION.txt)"
171
18
  echo
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ echo
6
+ echo "Message DB"
7
+ echo
8
+ echo "Update the message_store database"
9
+ echo
10
+ echo "WARNING:"
11
+ echo "This script updates a pre-v1 message_store database to Message DB v1.x"
12
+ echo "Do not run this script on a Message DB v1 database"
13
+ echo
14
+ echo "- Press CTRL+C to stop this script from running"
15
+ echo "- Press RETURN to allow the script to proceed"
16
+ echo
17
+ read
18
+
19
+ function script_dir {
20
+ val="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21
+ echo "$val"
22
+ }
23
+
24
+ base="$(script_dir)/.."
25
+ echo $base
26
+
27
+ echo
28
+ echo "Updating Database"
29
+ echo "Version: $(cat $base/VERSION.txt)"
30
+ echo "= = ="
31
+
32
+ if [ -z ${DATABASE_NAME+x} ]; then
33
+ echo "(DATABASE_NAME is not set. Default will be used.)"
34
+ database=message_store
35
+ export DATABASE_NAME=$database
36
+ else
37
+ database=$DATABASE_NAME
38
+ fi
39
+ echo
40
+
41
+ if [ -z ${PGOPTIONS+x} ]; then
42
+ export PGOPTIONS='-c client_min_messages=warning'
43
+ fi
44
+
45
+ function delete-extensions {
46
+ echo "» pgcrypto extension"
47
+ psql $database -q -c "DROP EXTENSION IF EXISTS pgcrypto";
48
+ }
49
+
50
+ function delete-indexes {
51
+ echo "» messages_id_uniq_idx index"
52
+ psql $database -q -c "DROP INDEX IF EXISTS messages_id_uniq_idx CASCADE";
53
+
54
+ echo "» messages_stream_name_position_uniq_idx index"
55
+ psql $database -q -c "DROP INDEX IF EXISTS messages_stream_name_position_uniq_idx";
56
+
57
+ echo "» messages_category_global_position_idx index"
58
+ psql $database -q -c "DROP INDEX IF EXISTS messages_category_global_position_idx";
59
+ }
60
+
61
+ function delete-views {
62
+ echo "» stream_summary view"
63
+ psql $database -q -c "DROP VIEW IF EXISTS stream_summary CASCADE";
64
+
65
+ echo "» type_summary view"
66
+ psql $database -q -c "DROP VIEW IF EXISTS type_summary CASCADE";
67
+
68
+ echo "» stream_type_summary view"
69
+ psql $database -q -c "DROP VIEW IF EXISTS stream_type_summary CASCADE";
70
+
71
+ echo "» type_stream_summary view"
72
+ psql $database -q -c "DROP VIEW IF EXISTS type_stream_summary CASCADE";
73
+
74
+ echo "» category_type_summary view"
75
+ psql $database -q -c "DROP VIEW IF EXISTS category_type_summary CASCADE";
76
+
77
+ echo "» type_category_summary view"
78
+ psql $database -q -c "DROP VIEW IF EXISTS type_category_summary CASCADE";
79
+ }
80
+
81
+ function delete-functions {
82
+ echo "» hash_64 function"
83
+ psql $database -q -c "DROP FUNCTION IF EXISTS hash_64 CASCADE";
84
+
85
+ echo "» category function"
86
+ psql $database -q -c "DROP FUNCTION IF EXISTS category CASCADE";
87
+
88
+ echo "» stream_version function"
89
+ psql $database -q -c "DROP FUNCTION IF EXISTS stream_version CASCADE";
90
+
91
+ echo "» write_message function"
92
+ psql $database -q -c "DROP FUNCTION IF EXISTS write_message CASCADE";
93
+
94
+ echo "» get_stream_messages function"
95
+ psql $database -q -c "DROP FUNCTION IF EXISTS get_stream_messages CASCADE";
96
+
97
+ echo "» get_category_messages function"
98
+ psql $database -q -c "DROP FUNCTION IF EXISTS get_category_messages CASCADE";
99
+
100
+ echo "» get_last_message function"
101
+ psql $database -q -c "DROP FUNCTION IF EXISTS get_last_message CASCADE";
102
+ }
103
+
104
+ function delete-extensions {
105
+ echo "» pgcrypto extension"
106
+ psql $database -q -c "DROP EXTENSION IF EXISTS pgcrypto CASCADE";
107
+ }
108
+
109
+ function create-schema {
110
+ echo "» message_store schema"
111
+ psql $database -q -f $base/schema/message-store.sql
112
+ }
113
+
114
+ function add-table-to-schema {
115
+ echo "» messages table"
116
+ psql $database -q -c "ALTER TABLE messages SET SCHEMA message_store";
117
+ }
118
+
119
+ function create-extensions {
120
+ echo "» pgcrypto extension"
121
+ psql $database -q -f $base/extensions/pgcrypto.sql
122
+ }
123
+
124
+ function set-default-value {
125
+ echo "» id column"
126
+ psql $database -q -c "ALTER TABLE message_store.messages ALTER COLUMN id SET DEFAULT gen_random_uuid()";
127
+ }
128
+
129
+ echo "Deleting Views"
130
+ echo "- - -"
131
+ delete-views
132
+ echo
133
+
134
+ echo "Deleting Indexes"
135
+ echo "- - -"
136
+ delete-indexes
137
+ echo
138
+
139
+ echo "Deleting Functions"
140
+ echo "- - -"
141
+ delete-functions
142
+ echo
143
+
144
+ echo "Deleting Extensions"
145
+ echo "- - -"
146
+ delete-extensions
147
+ echo
148
+
149
+ echo "Creating Schema"
150
+ echo "- - -"
151
+ create-schema
152
+ echo
153
+
154
+ echo "Creating Extensions"
155
+ echo "- - -"
156
+ create-extensions
157
+ echo
158
+
159
+ echo "Adding Table to Schema"
160
+ echo "- - -"
161
+ add-table-to-schema
162
+ echo
163
+
164
+ echo "Set Default Value for ID Column"
165
+ echo "- - -"
166
+ set-default-value
167
+ echo
168
+
169
+ # Install functions
170
+ source $base/install-functions.sh
171
+
172
+ # Install indexes
173
+ source $base/install-indexes.sh
174
+
175
+ # Install views
176
+ source $base/install-views.sh
177
+
178
+ # Install privileges
179
+ source $base/install-privileges.sh
180
+
181
+ echo "= = ="
182
+ echo "Done Updating Database"
183
+ echo "Version: $(cat $base/VERSION.txt)"
184
+ echo
@@ -2,4 +2,4 @@
2
2
 
3
3
  root = File.expand_path '../database', __dir__
4
4
 
5
- system `open #{root}`
5
+ puts root
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: message-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: scripts
10
10
  cert_chain: []
11
- date: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2019-12-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " "
14
14
  email: opensource@eventide-project.org
@@ -18,15 +18,14 @@ executables:
18
18
  - mdb-print-type-category-summary
19
19
  - mdb-install-views
20
20
  - mdb-delete-db
21
- - mdb-update-db
22
21
  - mdb-print-type-summary
23
22
  - mdb-print-stream-type-summary
24
23
  - mdb-install-privileges
25
24
  - mdb-recreate-db
26
25
  - mdb-print-messages
27
26
  - mdb-print-message-store-version
27
+ - mdb-print-database-scripts-dir
28
28
  - mdb-print-type-stream-summary
29
- - mdb-open-database-scripts-dir
30
29
  - mdb-write-test-message
31
30
  - mdb-install-indexes
32
31
  - mdb-install-functions
@@ -70,6 +69,7 @@ files:
70
69
  - database/print-type-stream-summary.sh
71
70
  - database/print-type-summary.sh
72
71
  - database/privileges/functions.sql
72
+ - database/privileges/schema.sql
73
73
  - database/privileges/sequence.sql
74
74
  - database/privileges/table.sql
75
75
  - database/privileges/views.sql
@@ -79,6 +79,7 @@ files:
79
79
  - database/types/message.sql
80
80
  - database/uninstall.sh
81
81
  - database/update.sh
82
+ - database/update/1.0.0.sh
82
83
  - database/views/category-type-summary.sql
83
84
  - database/views/stream-summary.sql
84
85
  - database/views/stream-type-summary.sql
@@ -93,8 +94,8 @@ files:
93
94
  - scripts/mdb-install-indexes
94
95
  - scripts/mdb-install-privileges
95
96
  - scripts/mdb-install-views
96
- - scripts/mdb-open-database-scripts-dir
97
97
  - scripts/mdb-print-category-type-summary
98
+ - scripts/mdb-print-database-scripts-dir
98
99
  - scripts/mdb-print-message-store-version
99
100
  - scripts/mdb-print-messages
100
101
  - scripts/mdb-print-stream-summary
@@ -103,7 +104,6 @@ files:
103
104
  - scripts/mdb-print-type-stream-summary
104
105
  - scripts/mdb-print-type-summary
105
106
  - scripts/mdb-recreate-db
106
- - scripts/mdb-update-db
107
107
  - scripts/mdb-write-test-message
108
108
  homepage: https://github.com/message-db/message-db
109
109
  licenses:
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- root = File.expand_path '../database', __dir__
4
- script_filename = 'update.sh'
5
- script_filepath = File.join root, script_filename
6
-
7
- system script_filepath