pg_party 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/pg_party.rb +4 -3
- data/lib/pg_party/hacks/postgresql_database_tasks.rb +25 -0
- data/lib/pg_party/version.rb +1 -1
- metadata +3 -3
- data/lib/pg_party/hacks/database_tasks.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2de3fe17d288034fdb27f8bef0d5c01bad51f568dae6bf92d3e4d547da88b0ac
|
4
|
+
data.tar.gz: b67b26808b013d71a393d3cdc1bd90d5b28c3e318661df1c56ebf8098407579b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d00eca782f9b7205a8c9bc3fd90a59c69a9e5ecefc828288c9d07ec61c94460e4344da121394aa6bb7b24d7a37a73e137b990ee504d7b78de28d7f29ac901f74
|
7
|
+
data.tar.gz: bc753cae774726c2edb8adad720c59b92214ecb75e1a955df8882f4a733d409c8170202dc65904547a71d8b6ecba65eed237c1d56b4c76f36d33c0ce739eff7b
|
data/README.md
CHANGED
@@ -59,7 +59,7 @@ These values can be accessed and set via `PgParty.config` and `PgParty.configure
|
|
59
59
|
- Length of time (in seconds) that cache entries are considered valid
|
60
60
|
- Default: `-1` (never expire cache entries)
|
61
61
|
- `schema_exclude_partitions`
|
62
|
-
- Whether to exclude child partitions in `rake db:structure:dump`
|
62
|
+
- Whether to exclude child partitions in `rake db:structure:dump`
|
63
63
|
- Default: `true`
|
64
64
|
|
65
65
|
Note that caching is done in-memory for each process of an application. Attaching / detaching partitions _will_ clear the cache, but only for the process that initiated the request. For multi-process web servers, it is recommended to use a TTL or disable caching entirely.
|
data/lib/pg_party.rb
CHANGED
@@ -40,10 +40,11 @@ ActiveSupport.on_load(:active_record) do
|
|
40
40
|
PgParty::Hacks::SchemaCache
|
41
41
|
)
|
42
42
|
|
43
|
-
require "
|
43
|
+
require "active_record/tasks/postgresql_database_tasks"
|
44
|
+
require "pg_party/hacks/postgresql_database_tasks"
|
44
45
|
|
45
|
-
ActiveRecord::Tasks::
|
46
|
-
PgParty::Hacks::
|
46
|
+
ActiveRecord::Tasks::PostgreSQLDatabaseTasks.prepend(
|
47
|
+
PgParty::Hacks::PostgreSQLDatabaseTasks
|
47
48
|
)
|
48
49
|
|
49
50
|
begin
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PgParty
|
4
|
+
module Hacks
|
5
|
+
module PostgreSQLDatabaseTasks
|
6
|
+
def run_cmd(cmd, args, action)
|
7
|
+
if action != "dumping" || !PgParty.config.schema_exclude_partitions
|
8
|
+
return super
|
9
|
+
end
|
10
|
+
|
11
|
+
partitions = begin
|
12
|
+
ActiveRecord::Base.connection.select_values(
|
13
|
+
"SELECT DISTINCT inhrelid::regclass::text FROM pg_inherits"
|
14
|
+
)
|
15
|
+
rescue
|
16
|
+
[]
|
17
|
+
end
|
18
|
+
|
19
|
+
excluded_tables = partitions.flat_map { |table| ["-T", "*.#{table}"] }
|
20
|
+
|
21
|
+
super(cmd, args + excluded_tables, action)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/pg_party/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_party
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Krage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -220,7 +220,7 @@ files:
|
|
220
220
|
- lib/pg_party/adapter_decorator.rb
|
221
221
|
- lib/pg_party/cache.rb
|
222
222
|
- lib/pg_party/config.rb
|
223
|
-
- lib/pg_party/hacks/
|
223
|
+
- lib/pg_party/hacks/postgresql_database_tasks.rb
|
224
224
|
- lib/pg_party/hacks/schema_cache.rb
|
225
225
|
- lib/pg_party/model/list_methods.rb
|
226
226
|
- lib/pg_party/model/methods.rb
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PgParty
|
4
|
-
module Hacks
|
5
|
-
module DatabaseTasks
|
6
|
-
def structure_dump(*)
|
7
|
-
old_ignore_list = ActiveRecord::SchemaDumper.ignore_tables
|
8
|
-
|
9
|
-
if PgParty.config.schema_exclude_partitions
|
10
|
-
new_ignore_list = partitions.map { |table| "*.#{table}" }
|
11
|
-
else
|
12
|
-
new_ignore_list = []
|
13
|
-
end
|
14
|
-
|
15
|
-
ActiveRecord::SchemaDumper.ignore_tables = old_ignore_list + new_ignore_list
|
16
|
-
|
17
|
-
super
|
18
|
-
ensure
|
19
|
-
ActiveRecord::SchemaDumper.ignore_tables = old_ignore_list
|
20
|
-
end
|
21
|
-
|
22
|
-
def partitions
|
23
|
-
ActiveRecord::Base.connection.select_values(
|
24
|
-
"SELECT DISTINCT inhrelid::regclass::text FROM pg_inherits"
|
25
|
-
)
|
26
|
-
rescue
|
27
|
-
[]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|