pg_easy_replicate 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- 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: 63ce4d3c583c90660cde52a6f0f138891af2b3eb6a2ccee039cbb57931a9a9aa
|
4
|
+
data.tar.gz: f2d8914e131a7eeaa0799c82f6d96ff4c4d765902fc0eed773927d58f8eae38d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec486fbc867215ea81e25f0fd001f0036d74d222a8782ea7525cd938e76cc782288ad42f90b878d9ddb95b00c20887d7e5ef29fb20b04f04451a6a0b59d495d7
|
7
|
+
data.tar.gz: d8704fef89664ce130801ccc4e9c8974fcc922e56e7570fc9260702c54da1fe366cbbede1b9c9f1da5aeb3d5ce5a27e1d991fdab1454f4ee7cf4d24af8684825
|
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
@@ -169,6 +169,11 @@ module PgEasyReplicate
|
|
169
169
|
logger.info("Dropping groups table")
|
170
170
|
Group.drop
|
171
171
|
end,
|
172
|
+
-> do
|
173
|
+
if options[:restore_connection_on_source_db]
|
174
|
+
restore_connections_on_source_db
|
175
|
+
end
|
176
|
+
end,
|
172
177
|
-> do
|
173
178
|
if options[:everything]
|
174
179
|
logger.info("Dropping schema")
|
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.7
|
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
|