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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4edfae292a9e881e90c5a845c46cb830e2335dcf4bc3f98cffeb8518a8db8326
4
- data.tar.gz: 0b4c27643bd2d7e215e6cf0377475f6c2f02f0eb64686107ce921bf5e499a04d
3
+ metadata.gz: e7291bb160de0db280d2e11a7b5e46d89bdd6b259ea2acf070ab302a80b27579
4
+ data.tar.gz: 7b5f1df7f16a833ce6f9fc2bdac7765e0d8835b6b271d029834a06a0f21bd3b7
5
5
  SHA512:
6
- metadata.gz: 184982dc8ebf187b5a130ddd1ec142e6c569382a092966bf45cd2c83df619cb0bf718ad64b53c97cd5ec38cbf3a7526fe4b4b60ef8ab1a9b65438b305e6b8751
7
- data.tar.gz: dc8faa56515d1c43eab8b7f220c6e64e368c99a1ae83da6bb7dcbc01609337ab1e6d9ae142668e2b39231013cb42609ea1d39ad5b904f7935593cca539d89f7f
6
+ metadata.gz: a066f7421b3be12ad1aa28017c9c680652f18477a37390fdaaf58efe2dc31aca28abc40715f15e33afbf628c973c2d8786d6d2818e22ea59e9ee6ca9c74dccd8
7
+ data.tar.gz: 45b5cfa989e4209ceddacc2582088ff712e45a17d34bfff423c30d3d350635cc894cc0f6c84dc5a68cb96ec4f0280d16cc8a2d4b108296543cde095b752312d6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pg_easy_replicate (0.3.5)
4
+ pg_easy_replicate (0.3.6)
5
5
  ougai (~> 2.0.0)
6
6
  pg (~> 1.5.3)
7
7
  pg_query (~> 5.1.0)
@@ -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", "Sends a notification with replication status to a specified url"
167
- method_option :group_name, aliases: "-g", required: true, desc: "Name of the group previously provisioned"
168
- method_option :url, aliases: "-u", required: true, desc: "URL for notification"
169
- method_option :frequency, aliases: "-f", type: :numeric, default: 10, desc: "Frequency for sending stats to the endpoint provided"
170
- method_option :timeout, aliases: "-t", type: :numeric, default: 10, desc: "Timeout for the notify request"
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(options[:group_name], options[:url], options[:frequency], options[:timeout])
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: true)
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("Options --tables(-t) and --exclude-tables(-e) cannot be used together.")
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 && (schema_name.nil? || schema_name == "")
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(group_name)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgEasyReplicate
4
- VERSION = "0.3.5"
4
+ VERSION = "0.3.6"
5
5
  end
@@ -213,6 +213,11 @@ module PgEasyReplicate
213
213
  end
214
214
  end
215
215
  end,
216
+ -> do
217
+ if options[:restore_connection_on_source_db]
218
+ restore_connections_on_source_db
219
+ end
220
+ end,
216
221
  ]
217
222
 
218
223
  cleanup_steps.each do |step|
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
- # echo "=== Pushing tags to github ===="
18
- # git tag v"$VERSION"
19
- # git push origin --tags
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.5
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-18 00:00:00.000000000 Z
11
+ date: 2024-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ougai