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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4edfae292a9e881e90c5a845c46cb830e2335dcf4bc3f98cffeb8518a8db8326
4
- data.tar.gz: 0b4c27643bd2d7e215e6cf0377475f6c2f02f0eb64686107ce921bf5e499a04d
3
+ metadata.gz: 63ce4d3c583c90660cde52a6f0f138891af2b3eb6a2ccee039cbb57931a9a9aa
4
+ data.tar.gz: f2d8914e131a7eeaa0799c82f6d96ff4c4d765902fc0eed773927d58f8eae38d
5
5
  SHA512:
6
- metadata.gz: 184982dc8ebf187b5a130ddd1ec142e6c569382a092966bf45cd2c83df619cb0bf718ad64b53c97cd5ec38cbf3a7526fe4b4b60ef8ab1a9b65438b305e6b8751
7
- data.tar.gz: dc8faa56515d1c43eab8b7f220c6e64e368c99a1ae83da6bb7dcbc01609337ab1e6d9ae142668e2b39231013cb42609ea1d39ad5b904f7935593cca539d89f7f
6
+ metadata.gz: ec486fbc867215ea81e25f0fd001f0036d74d222a8782ea7525cd938e76cc782288ad42f90b878d9ddb95b00c20887d7e5ef29fb20b04f04451a6a0b59d495d7
7
+ data.tar.gz: d8704fef89664ce130801ccc4e9c8974fcc922e56e7570fc9260702c54da1fe366cbbede1b9c9f1da5aeb3d5ce5a27e1d991fdab1454f4ee7cf4d24af8684825
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.7)
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.7"
5
5
  end
@@ -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
- # 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.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-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