pg_party 1.9.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 +4 -4
- data/README.md +4 -4
- data/lib/pg_party/hacks/postgresql_database_tasks.rb +33 -7
- data/lib/pg_party/version.rb +1 -1
- data/lib/pg_party.rb +9 -3
- metadata +7 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4a5de0a6fbcae2e9d51dc6e4cd716f1c5954431a9e76285c92efb325cfb9e2fd
|
|
4
|
+
data.tar.gz: 7c501a49669077693de4c852a658be4fd62858c515cc28e818034999ccc5ff65
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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: 7.
|
|
29
|
-
- Ruby: 3.2, latest (currently 3.
|
|
30
|
-
- PostgreSQL:
|
|
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:
|
|
@@ -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
|
-
|
|
14
|
-
|
|
15
|
-
pg_inherits
|
|
16
|
-
|
|
17
|
-
WHERE
|
|
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",
|
|
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
|
data/lib/pg_party/version.rb
CHANGED
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
|
-
|
|
41
|
-
|
|
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.
|
|
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:
|
|
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: '7.
|
|
18
|
+
version: '7.2'
|
|
20
19
|
- - "<"
|
|
21
20
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '8.
|
|
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: '7.
|
|
28
|
+
version: '7.2'
|
|
30
29
|
- - "<"
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '8.
|
|
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.
|
|
266
|
-
signing_key:
|
|
263
|
+
rubygems_version: 3.6.2
|
|
267
264
|
specification_version: 4
|
|
268
265
|
summary: ActiveRecord PostgreSQL Partitioning
|
|
269
266
|
test_files: []
|