partition_gardener 0.3.1 → 0.3.2

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: ca1610832b9a6faff9b6aaf01cbe61b7058df2c7d722911e853e618d8c75c225
4
- data.tar.gz: 66740e3912d495366737997cb09c9a1b97972c44763b8eb39a2722d2e837e38e
3
+ metadata.gz: 3f0145fb9ce93ecb6ec1edff17262ee7a704832dfc8f5cf0ecd3c2d924efeab0
4
+ data.tar.gz: 693e589937825259906c6d7846117668b9f902a49d468d944b1c4226e1e40bd6
5
5
  SHA512:
6
- metadata.gz: '068c551bb1e30ba4cbc85407d0fe9204cc2d1e1c3f325fff12aa501be5bcf4038b5af782aed46db0be4ebff458fc2d14956b0879a670da5307814d51c26d1e8e'
7
- data.tar.gz: 71b0cc6d6695d74dc053265fc69dcef955b952792194ec14e1edb7b177ac1071146b9b7c4db34c4ac13025cac85a3a4655d9f0199b4a043b66894b0c0c804362
6
+ metadata.gz: 2d8cb08e6ffe79c0f4d59894482495edc55c9465d6b236d0a9c37003faac6523a24a502a564834637862af3ccb4d240830b1e2f23c45b322dac382a224f857d9
7
+ data.tar.gz: 5434286fe8cfdd3e46c769862973b0b7d362b1dfd1184b24673f1fc8f8df01a19d2c7a12d148257a692338c32de37f29b51a987895005cb82c4cf728339c4f04
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 0.3.2 (2026-07-13)
6
+
7
+ - Route `HotSwitchConcern` DDL through `connection.execute` instead of `ActiveRecord::Migration#execute` so migration safety tools such as Strong Migrations do not intercept hot-switch SQL.
8
+
3
9
  ## 0.3.1 (2026-07-09)
4
10
 
5
11
  - Add partition engines guide mapping portable maintenance patterns to MySQL, Oracle, SQL Server, Db2, YugabyteDB, and Aurora
@@ -19,10 +19,11 @@ root logger 1.7.0 Ruby|BSD-2-Clause
19
19
  root minitest 6.0.6 MIT
20
20
  root parallel 2.1.0 MIT
21
21
  root parser 3.3.11.1 MIT
22
- root partition_gardener 0.3.1 MIT
22
+ root partition_gardener 0.3.2 MIT
23
23
  root pg 1.6.3 BSD-2-Clause
24
- root polyrun 1.5.0 MIT
24
+ root polyrun 2.2.0 MIT
25
25
  root prism 1.9.0 MIT
26
+ root prosopite 2.2.0 Apache-2.0
26
27
  root racc 1.8.1 Ruby|BSD-2-Clause
27
28
  root rack 3.2.6 MIT
28
29
  root rainbow 3.1.1 MIT
@@ -49,7 +49,7 @@ module PartitionGardener
49
49
  CREATE TABLE IF NOT EXISTS #{quoted_table(partition_name)} PARTITION OF #{quoted_table(partitioned_table)}
50
50
  FOR VALUES #{for_values_clause}
51
51
  SQL
52
- execute(sql)
52
+ run_sql(sql)
53
53
  say "Created partition #{partition_name}"
54
54
  end
55
55
 
@@ -63,11 +63,11 @@ module PartitionGardener
63
63
  say "Analyzing shadow partitions for #{partitioned_table}"
64
64
 
65
65
  fetch_partitions(partitioned_table).each do |partition|
66
- execute "ANALYZE #{partition}"
66
+ run_sql "ANALYZE #{partition}"
67
67
  say "Analyzed #{partition}"
68
68
  end
69
69
 
70
- execute "ANALYZE #{quoted_table(partitioned_table)}"
70
+ run_sql "ANALYZE #{quoted_table(partitioned_table)}"
71
71
  say "Analyzed #{partitioned_table}"
72
72
  end
73
73
 
@@ -83,16 +83,16 @@ module PartitionGardener
83
83
  END;
84
84
  $$ LANGUAGE plpgsql;
85
85
  SQL
86
- execute(sql)
86
+ run_sql(sql)
87
87
 
88
- execute "DROP TRIGGER IF EXISTS #{trigger_name} ON #{quoted_table(table_name)}"
88
+ run_sql "DROP TRIGGER IF EXISTS #{trigger_name} ON #{quoted_table(table_name)}"
89
89
  sql = <<~SQL
90
90
  CREATE TRIGGER #{trigger_name}
91
91
  BEFORE INSERT OR UPDATE OR DELETE ON #{quoted_table(table_name)}
92
92
  FOR EACH ROW
93
93
  EXECUTE FUNCTION #{function_name}();
94
94
  SQL
95
- execute(sql)
95
+ run_sql(sql)
96
96
 
97
97
  say "Added write-block trigger to #{table_name}"
98
98
  end
@@ -101,8 +101,8 @@ module PartitionGardener
101
101
  trigger_name = "#{initial_table_name}_write_block_trigger"
102
102
  function_name = "#{initial_table_name}_write_block_function"
103
103
 
104
- execute "DROP TRIGGER IF EXISTS #{trigger_name} ON #{quoted_table(table_name)}"
105
- execute "DROP FUNCTION IF EXISTS #{function_name}()"
104
+ run_sql "DROP TRIGGER IF EXISTS #{trigger_name} ON #{quoted_table(table_name)}"
105
+ run_sql "DROP FUNCTION IF EXISTS #{function_name}()"
106
106
  say "Removed write-block trigger from #{table_name}"
107
107
  end
108
108
 
@@ -124,7 +124,7 @@ module PartitionGardener
124
124
  )
125
125
  SQL
126
126
 
127
- active_count = execute(active_transactions_sql).first["count"].to_i
127
+ active_count = run_sql(active_transactions_sql).first["count"].to_i
128
128
  if active_count.zero?
129
129
  say "No active transactions on #{table_name}"
130
130
  return true
@@ -197,7 +197,7 @@ module PartitionGardener
197
197
  WHERE #{window_predicate}
198
198
  SQL
199
199
 
200
- records_to_sync = execute(count_sql).first["count"].to_i
200
+ records_to_sync = run_sql(count_sql).first["count"].to_i
201
201
  if records_to_sync.zero?
202
202
  say "No records to sync - tables are already in sync"
203
203
  return
@@ -237,7 +237,7 @@ module PartitionGardener
237
237
  #{conflict_update_sql}
238
238
  SQL
239
239
 
240
- result = execute(sync_sql)
240
+ result = run_sql(sync_sql)
241
241
  synced_batch = result.cmd_tuples
242
242
  break if synced_batch.zero?
243
243
 
@@ -257,7 +257,7 @@ module PartitionGardener
257
257
  ORDER BY ordinal_position
258
258
  SQL
259
259
 
260
- execute(sql).map { |row| row["column_name"] }
260
+ run_sql(sql).map { |row| row["column_name"] }
261
261
  end
262
262
 
263
263
  alias_method :get_table_columns, :table_columns
@@ -267,8 +267,8 @@ module PartitionGardener
267
267
  current_table = config[:current_table]
268
268
  partitioned_table = config[:partitioned_table]
269
269
 
270
- current_count = execute("SELECT COUNT(*) AS count FROM #{quoted_table(current_table)}").first["count"].to_i
271
- partitioned_count = execute("SELECT COUNT(*) AS count FROM #{quoted_table(partitioned_table)}").first["count"].to_i
270
+ current_count = run_sql("SELECT COUNT(*) AS count FROM #{quoted_table(current_table)}").first["count"].to_i
271
+ partitioned_count = run_sql("SELECT COUNT(*) AS count FROM #{quoted_table(partitioned_table)}").first["count"].to_i
272
272
 
273
273
  say "Count comparison:"
274
274
  say " #{current_table}: #{current_count}"
@@ -288,7 +288,7 @@ module PartitionGardener
288
288
  FROM pg_catalog.pg_inherits
289
289
  WHERE inhparent = #{connection.quote(table_name)}::regclass
290
290
  SQL
291
- execute(sql).map { |row| row["child"] }
291
+ run_sql(sql).map { |row| row["child"] }
292
292
  end
293
293
 
294
294
  def hot_switch_tables
@@ -306,10 +306,10 @@ module PartitionGardener
306
306
  transaction do
307
307
  apply_swap_lock_timeout!
308
308
 
309
- execute "ALTER TABLE #{quoted_table(current_table)} RENAME TO #{quoted_table(old_table)}"
309
+ run_sql "ALTER TABLE #{quoted_table(current_table)} RENAME TO #{quoted_table(old_table)}"
310
310
  say "Renamed #{current_table} to #{old_table}"
311
311
 
312
- execute "ALTER TABLE #{quoted_table(partitioned_table)} RENAME TO #{quoted_table(current_table)}"
312
+ run_sql "ALTER TABLE #{quoted_table(partitioned_table)} RENAME TO #{quoted_table(current_table)}"
313
313
  say "Renamed #{partitioned_table} to #{current_table}"
314
314
 
315
315
  rename_partition_children!(current_table, partitioned_table, current_table)
@@ -336,10 +336,10 @@ module PartitionGardener
336
336
  transaction do
337
337
  apply_swap_lock_timeout!
338
338
 
339
- execute "ALTER TABLE #{quoted_table(current_table)} RENAME TO #{quoted_table(partitioned_table)}"
339
+ run_sql "ALTER TABLE #{quoted_table(current_table)} RENAME TO #{quoted_table(partitioned_table)}"
340
340
  say "Renamed #{current_table} to #{partitioned_table}"
341
341
 
342
- execute "ALTER TABLE #{quoted_table(old_table)} RENAME TO #{quoted_table(current_table)}"
342
+ run_sql "ALTER TABLE #{quoted_table(old_table)} RENAME TO #{quoted_table(current_table)}"
343
343
  say "Renamed #{old_table} to #{current_table}"
344
344
 
345
345
  rename_partition_children!(partitioned_table, current_table, partitioned_table)
@@ -356,7 +356,7 @@ module PartitionGardener
356
356
  sql = <<~SQL
357
357
  SELECT pg_get_serial_sequence(#{connection.quote(qualified_table)}, #{connection.quote(column_name)}) AS sequence_name
358
358
  SQL
359
- result = execute(sql).first
359
+ result = run_sql(sql).first
360
360
  sequence_name = result["sequence_name"]
361
361
  next if Blank.blank?(sequence_name)
362
362
 
@@ -400,7 +400,7 @@ module PartitionGardener
400
400
  timeout = swap_lock_timeout_setting
401
401
  return if timeout.nil?
402
402
 
403
- execute "SET LOCAL lock_timeout = #{connection.quote(timeout)}"
403
+ run_sql "SET LOCAL lock_timeout = #{connection.quote(timeout)}"
404
404
  end
405
405
 
406
406
  def rename_partition_children!(parent_table, from_prefix, to_prefix)
@@ -409,14 +409,14 @@ module PartitionGardener
409
409
  next if partition_name.include?(to_prefix)
410
410
 
411
411
  new_partition_name = partition_name.gsub(from_prefix, to_prefix)
412
- execute "ALTER TABLE #{partition} RENAME TO #{new_partition_name}"
412
+ run_sql "ALTER TABLE #{partition} RENAME TO #{new_partition_name}"
413
413
  say "Renamed #{partition} to #{new_partition_name}"
414
414
  end
415
415
  end
416
416
 
417
417
  def repoint_serial_sequences!(table_name, sequence_pairs)
418
418
  sequence_pairs.each do |column_name, sequence_name|
419
- execute "ALTER SEQUENCE #{sequence_name} OWNED BY #{quoted_table(table_name)}.#{connection.quote_column_name(column_name)}"
419
+ run_sql "ALTER SEQUENCE #{sequence_name} OWNED BY #{quoted_table(table_name)}.#{connection.quote_column_name(column_name)}"
420
420
  say "Repointed #{sequence_name} to #{table_name}.#{column_name}"
421
421
  end
422
422
  end
@@ -430,6 +430,10 @@ module PartitionGardener
430
430
  ["id", base_key]
431
431
  end
432
432
 
433
+ def run_sql(sql)
434
+ connection.execute(sql)
435
+ end
436
+
433
437
  def connection
434
438
  PartitionGardener.configuration.connection
435
439
  end
@@ -1,3 +1,3 @@
1
1
  module PartitionGardener
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: partition_gardener
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Makarov
@@ -81,18 +81,32 @@ dependencies:
81
81
  version: '3'
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: polyrun
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 2.2.0
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 2.2.0
96
+ - !ruby/object:Gem::Dependency
97
+ name: prosopite
84
98
  requirement: !ruby/object:Gem::Requirement
85
99
  requirements:
86
100
  - - "~>"
87
101
  - !ruby/object:Gem::Version
88
- version: 1.5.0
102
+ version: '2.0'
89
103
  type: :development
90
104
  prerelease: false
91
105
  version_requirements: !ruby/object:Gem::Requirement
92
106
  requirements:
93
107
  - - "~>"
94
108
  - !ruby/object:Gem::Version
95
- version: 1.5.0
109
+ version: '2.0'
96
110
  - !ruby/object:Gem::Dependency
97
111
  name: rspec_junit_formatter
98
112
  requirement: !ruby/object:Gem::Requirement
@@ -363,7 +377,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
363
377
  - !ruby/object:Gem::Version
364
378
  version: '0'
365
379
  requirements: []
366
- rubygems_version: 4.0.3
380
+ rubygems_version: 4.0.6
367
381
  specification_version: 4
368
382
  summary: Partition Gardener — PostgreSQL partition lifecycle maintenance
369
383
  test_files: []