pg_party 1.8.0 → 1.10.0

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: 2a925ebf451625606acfdf6a4d1dbdde4a2a21e0ac98ccbbeabb6eb91d5d998e
4
- data.tar.gz: 5f157ce75a78a79ff14fe0aa7eead4f045339a823193baa58562d8fd9e897a84
3
+ metadata.gz: 4a5de0a6fbcae2e9d51dc6e4cd716f1c5954431a9e76285c92efb325cfb9e2fd
4
+ data.tar.gz: 7c501a49669077693de4c852a658be4fd62858c515cc28e818034999ccc5ff65
5
5
  SHA512:
6
- metadata.gz: 6b35cc8959cca3f09d504ebeb0d83a16633c803d858fb80398f6ebd3fd78c9599670fa3b3601ae96a510d5708a4b9cbcc201a2bd68100c794de103cd6817838d
7
- data.tar.gz: e1b87b04b9a418326b2a06536d6477d29188332e5c01592241c740dd88deeb34c6d29570b5c47a25f628ed7facc5d41c02c9d626680db030a0460ae1892ae03a
6
+ metadata.gz: 6d4835045737f837d1257b621cc65773425e183f57fb257043e35c79859b9821704a454d92bddbf30e0538d4b3f14c08a74f15229af079129a533d53147b84ef
7
+ data.tar.gz: ca99db8c60fea0994aa2766427ad254942cb5c97c82d9e11a8ba4e89b31ee885948688f826aca8f00a0658974b8c8d46742bdadd37a99108e2e61a54d784d981
data/README.md CHANGED
@@ -25,9 +25,9 @@
25
25
 
26
26
  This gem is tested against:
27
27
 
28
- - Rails: 6.1, 7.0, 7.1, 7.2
29
- - Ruby: 3.0, latest (currently 3.2 at the time of this commit)
30
- - PostgreSQL: 11, 12, 13, 14, 15, 16
28
+ - Rails: 7.2, 8.0, 8.1
29
+ - Ruby: 3.2, latest (currently 3.4 at the time of this commit)
30
+ - PostgreSQL: 14, 15, 16, 17, 18
31
31
 
32
32
  ## Future Work
33
33
 
@@ -636,7 +636,7 @@ The development / test environment relies heavily on [Docker](https://docs.docke
636
636
  Start the containers in the background:
637
637
 
638
638
  ```
639
- $ docker-compose up -d
639
+ $ docker-compose up -d --build
640
640
  ```
641
641
 
642
642
  Install dependencies:
@@ -155,7 +155,7 @@ module PgParty
155
155
 
156
156
  # Postgres limits index name to 63 bytes (characters). We will use 8 characters for a `_random_suffix`
157
157
  # on partitions to ensure no conflicts, leaving 55 chars for the specified index name
158
- raise ArgumentError 'index name is too long - must be 55 characters or fewer' if index_name.length > 55
158
+ raise ArgumentError, 'index name is too long - must be 55 characters or fewer' if index_name.length > 55
159
159
 
160
160
  recursive_add_index(
161
161
  table_name: table_name,
@@ -2,6 +2,11 @@
2
2
 
3
3
  module PgParty
4
4
  module Hacks
5
+ # We should really use ActiveRecord::SchemaDumper.ignore_tables
6
+ # but it appears there's a bug in the code that generates the args
7
+ # for pg_dump. I believe we need to exclude based on the fully
8
+ # qualified name (or a pattern like *.table_name) but the Rails
9
+ # code does not do this and we need to hack into low-level methods.
5
10
  module PostgreSQLDatabaseTasks
6
11
  def run_cmd(cmd, args, action)
7
12
  if action != "dumping" || !PgParty.config.schema_exclude_partitions
@@ -9,18 +14,39 @@ module PgParty
9
14
  end
10
15
 
11
16
  partitions = ActiveRecord::Base.connection.select_values(<<-SQL, "SCHEMA")
12
- SELECT
13
- inhrelid::regclass::text
14
- FROM
15
- pg_inherits
16
- JOIN pg_class AS p ON inhparent = p.oid
17
- WHERE p.relkind = 'p'
17
+ SELECT CONCAT(pg_namespace.nspname, '.', child.relname)
18
+ FROM pg_inherits
19
+ JOIN pg_class parent ON pg_inherits.inhparent = parent.oid
20
+ JOIN pg_class child ON pg_inherits.inhrelid = child.oid
21
+ JOIN pg_namespace ON parent.relnamespace = pg_namespace.oid
22
+ WHERE parent.relkind = 'p'
18
23
  SQL
19
24
 
20
- excluded_tables = partitions.flat_map { |table| ["-T", "*.#{table}"] }
25
+ excluded_tables = partitions.flat_map { |table| ["-T", table] }
21
26
 
22
27
  super(cmd, args + excluded_tables, action)
23
28
  end
24
29
  end
30
+
31
+ module PostgreSQLDatabaseTasks81
32
+ def run_cmd(cmd, *args)
33
+ if cmd != "pg_dump" || !PgParty.config.schema_exclude_partitions
34
+ return super
35
+ end
36
+
37
+ partitions = ActiveRecord::Base.connection.select_values(<<-SQL, "SCHEMA")
38
+ SELECT CONCAT(pg_namespace.nspname, '.', child.relname)
39
+ FROM pg_inherits
40
+ JOIN pg_class parent ON pg_inherits.inhparent = parent.oid
41
+ JOIN pg_class child ON pg_inherits.inhrelid = child.oid
42
+ JOIN pg_namespace ON parent.relnamespace = pg_namespace.oid
43
+ WHERE parent.relkind = 'p'
44
+ SQL
45
+
46
+ excluded_tables = partitions.flat_map { |table| ["-T", table] }
47
+
48
+ super(cmd, *args, *excluded_tables)
49
+ end
50
+ end
25
51
  end
26
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgParty
4
- VERSION = "1.8.0"
4
+ VERSION = "1.10.0"
5
5
  end
data/lib/pg_party.rb CHANGED
@@ -37,9 +37,15 @@ ActiveSupport.on_load(:active_record) do
37
37
  require "active_record/tasks/postgresql_database_tasks"
38
38
  require "pg_party/hacks/postgresql_database_tasks"
39
39
 
40
- ActiveRecord::Tasks::PostgreSQLDatabaseTasks.prepend(
41
- PgParty::Hacks::PostgreSQLDatabaseTasks
42
- )
40
+ if Rails.gem_version >= Gem::Version.new("8.1")
41
+ ActiveRecord::Tasks::PostgreSQLDatabaseTasks.prepend(
42
+ PgParty::Hacks::PostgreSQLDatabaseTasks81
43
+ )
44
+ else
45
+ ActiveRecord::Tasks::PostgreSQLDatabaseTasks.prepend(
46
+ PgParty::Hacks::PostgreSQLDatabaseTasks
47
+ )
48
+ end
43
49
 
44
50
  begin
45
51
  require "active_record/connection_adapters/postgresql_adapter"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_party
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Krage
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-08-29 00:00:00.000000000 Z
10
+ date: 2025-11-14 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activerecord
@@ -16,20 +15,20 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '6.1'
18
+ version: '7.2'
20
19
  - - "<"
21
20
  - !ruby/object:Gem::Version
22
- version: '8.0'
21
+ version: '8.2'
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- version: '6.1'
28
+ version: '7.2'
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
- version: '8.0'
31
+ version: '8.2'
33
32
  - !ruby/object:Gem::Dependency
34
33
  name: parallel
35
34
  requirement: !ruby/object:Gem::Requirement
@@ -247,7 +246,6 @@ homepage: https://github.com/rkrage/pg_party
247
246
  licenses:
248
247
  - MIT
249
248
  metadata: {}
250
- post_install_message:
251
249
  rdoc_options: []
252
250
  require_paths:
253
251
  - lib
@@ -262,8 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
260
  - !ruby/object:Gem::Version
263
261
  version: '0'
264
262
  requirements: []
265
- rubygems_version: 3.3.7
266
- signing_key:
263
+ rubygems_version: 3.6.2
267
264
  specification_version: 4
268
265
  summary: ActiveRecord PostgreSQL Partitioning
269
266
  test_files: []