pg_easy_replicate 0.3.5 → 0.3.6
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/Gemfile.lock +1 -1
- data/lib/pg_easy_replicate/cli.rb +31 -6
- data/lib/pg_easy_replicate/group.rb +2 -1
- data/lib/pg_easy_replicate/helper.rb +14 -3
- data/lib/pg_easy_replicate/orchestrate.rb +1 -9
- data/lib/pg_easy_replicate/version.rb +1 -1
- data/lib/pg_easy_replicate.rb +5 -0
- data/scripts/release.sh +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7291bb160de0db280d2e11a7b5e46d89bdd6b259ea2acf070ab302a80b27579
|
4
|
+
data.tar.gz: 7b5f1df7f16a833ce6f9fc2bdac7765e0d8835b6b271d029834a06a0f21bd3b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a066f7421b3be12ad1aa28017c9c680652f18477a37390fdaaf58efe2dc31aca28abc40715f15e33afbf628c973c2d8786d6d2818e22ea59e9ee6ca9c74dccd8
|
7
|
+
data.tar.gz: 45b5cfa989e4209ceddacc2582088ff712e45a17d34bfff423c30d3d350635cc894cc0f6c84dc5a68cb96ec4f0280d16cc8a2d4b108296543cde095b752312d6
|
data/Gemfile.lock
CHANGED
@@ -78,6 +78,11 @@ module PgEasyReplicate
|
|
78
78
|
aliases: "-s",
|
79
79
|
desc:
|
80
80
|
"Cleans up the publication and subscription for the respective group"
|
81
|
+
method_option :restore_connection_on_source_db,
|
82
|
+
aliases: "-r",
|
83
|
+
type: :boolean,
|
84
|
+
default: false,
|
85
|
+
desc: "Restore connection on source db after switchover"
|
81
86
|
def cleanup
|
82
87
|
PgEasyReplicate.cleanup(options)
|
83
88
|
end
|
@@ -163,14 +168,34 @@ module PgEasyReplicate
|
|
163
168
|
end
|
164
169
|
end
|
165
170
|
|
166
|
-
desc "notify",
|
167
|
-
|
168
|
-
method_option :
|
169
|
-
|
170
|
-
|
171
|
+
desc "notify",
|
172
|
+
"Sends a notification with replication status to a specified url"
|
173
|
+
method_option :group_name,
|
174
|
+
aliases: "-g",
|
175
|
+
required: true,
|
176
|
+
desc: "Name of the group previously provisioned"
|
177
|
+
method_option :url,
|
178
|
+
aliases: "-u",
|
179
|
+
required: true,
|
180
|
+
desc: "URL for notification"
|
181
|
+
method_option :frequency,
|
182
|
+
aliases: "-f",
|
183
|
+
type: :numeric,
|
184
|
+
default: 10,
|
185
|
+
desc: "Frequency for sending stats to the endpoint provided"
|
186
|
+
method_option :timeout,
|
187
|
+
aliases: "-t",
|
188
|
+
type: :numeric,
|
189
|
+
default: 10,
|
190
|
+
desc: "Timeout for the notify request"
|
171
191
|
|
172
192
|
def notify
|
173
|
-
PgEasyReplicate::Stats.notify(
|
193
|
+
PgEasyReplicate::Stats.notify(
|
194
|
+
options[:group_name],
|
195
|
+
options[:url],
|
196
|
+
options[:frequency],
|
197
|
+
options[:timeout],
|
198
|
+
)
|
174
199
|
end
|
175
200
|
|
176
201
|
desc "list_ddl_changes", "Lists recent DDL changes in the source database"
|
@@ -20,7 +20,7 @@ module PgEasyReplicate
|
|
20
20
|
column(:updated_at, Time, default: Sequel::CURRENT_TIMESTAMP)
|
21
21
|
column(:started_at, Time)
|
22
22
|
column(:failed_at, Time)
|
23
|
-
column(:recreate_indices_post_copy, TrueClass, default:
|
23
|
+
column(:recreate_indices_post_copy, TrueClass, default: false)
|
24
24
|
column(:switchover_completed_at, Time)
|
25
25
|
end
|
26
26
|
ensure
|
@@ -44,6 +44,7 @@ module PgEasyReplicate
|
|
44
44
|
schema_name: options[:schema_name],
|
45
45
|
started_at: options[:started_at],
|
46
46
|
failed_at: options[:failed_at],
|
47
|
+
recreate_indices_post_copy: options[:recreate_indices_post_copy],
|
47
48
|
)
|
48
49
|
rescue => e
|
49
50
|
abort_with("Adding group entry failed: #{e.message}")
|
@@ -75,7 +75,7 @@ module PgEasyReplicate
|
|
75
75
|
|
76
76
|
def determine_tables(conn_string:, list: "", exclude_list: "", schema: nil)
|
77
77
|
schema ||= "public"
|
78
|
-
|
78
|
+
|
79
79
|
tables = convert_to_array(list)
|
80
80
|
exclude_tables = convert_to_array(exclude_list)
|
81
81
|
validate_table_lists(tables, exclude_tables, schema)
|
@@ -115,14 +115,25 @@ module PgEasyReplicate
|
|
115
115
|
exclude_table_list = convert_to_array(exclude_tables)
|
116
116
|
|
117
117
|
if !table_list.empty? && !exclude_table_list.empty?
|
118
|
-
abort_with(
|
118
|
+
abort_with(
|
119
|
+
"Options --tables(-t) and --exclude-tables(-e) cannot be used together.",
|
120
|
+
)
|
119
121
|
elsif !table_list.empty?
|
120
122
|
if table_list.size > 0 && (schema_name.nil? || schema_name == "")
|
121
123
|
abort_with("Schema name is required if tables are passed")
|
122
124
|
end
|
123
|
-
elsif exclude_table_list.size > 0 &&
|
125
|
+
elsif exclude_table_list.size > 0 &&
|
126
|
+
(schema_name.nil? || schema_name == "")
|
124
127
|
abort_with("Schema name is required if exclude tables are passed")
|
125
128
|
end
|
126
129
|
end
|
130
|
+
|
131
|
+
def restore_connections_on_source_db
|
132
|
+
logger.info("Restoring connections")
|
133
|
+
|
134
|
+
alter_sql =
|
135
|
+
"ALTER USER #{quote_ident(db_user(source_db_url))} set default_transaction_read_only = false"
|
136
|
+
Query.run(query: alter_sql, connection_url: source_db_url)
|
137
|
+
end
|
127
138
|
end
|
128
139
|
end
|
@@ -254,7 +254,7 @@ module PgEasyReplicate
|
|
254
254
|
)
|
255
255
|
end
|
256
256
|
rescue => e
|
257
|
-
restore_connections_on_source_db
|
257
|
+
restore_connections_on_source_db
|
258
258
|
abort_with("Switchover failed: #{e.message}")
|
259
259
|
end
|
260
260
|
|
@@ -314,14 +314,6 @@ module PgEasyReplicate
|
|
314
314
|
raise "Unable to revoke connections on source db: #{e.message}"
|
315
315
|
end
|
316
316
|
|
317
|
-
def restore_connections_on_source_db(group_name)
|
318
|
-
logger.info("Restoring connections")
|
319
|
-
|
320
|
-
alter_sql =
|
321
|
-
"ALTER USER #{quote_ident(db_user(source_db_url))} set default_transaction_read_only = false"
|
322
|
-
Query.run(query: alter_sql, connection_url: source_db_url)
|
323
|
-
end
|
324
|
-
|
325
317
|
def refresh_sequences(conn_string:, schema: nil)
|
326
318
|
logger.info("Refreshing sequences")
|
327
319
|
sql = <<~SQL
|
data/lib/pg_easy_replicate.rb
CHANGED
data/scripts/release.sh
CHANGED
@@ -14,9 +14,9 @@ gem push pg_easy_replicate-"$VERSION".gem
|
|
14
14
|
echo "=== Sleeping for 15s ===="
|
15
15
|
sleep 15
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
echo "=== Pushing tags to github ===="
|
18
|
+
git tag v"$VERSION"
|
19
|
+
git push origin --tags
|
20
20
|
|
21
21
|
echo "=== Cleaning up ===="
|
22
22
|
rm pg_easy_replicate-"$VERSION".gem
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_easy_replicate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shayon Mukherjee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ougai
|