pg_party 1.2.0 → 1.2.1

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: 5996516e7f3b76373b6fc4f9a29c9e31f48d9edb086b7e0f217031f0ed3707ea
4
- data.tar.gz: d4e5d12b2bdb80ab928153efe9ec49e11b7e6e413f0a0edbeddfe2f24a7d4276
3
+ metadata.gz: 2de3fe17d288034fdb27f8bef0d5c01bad51f568dae6bf92d3e4d547da88b0ac
4
+ data.tar.gz: b67b26808b013d71a393d3cdc1bd90d5b28c3e318661df1c56ebf8098407579b
5
5
  SHA512:
6
- metadata.gz: fac73650e2065c300fabb4ad826e59b8877310033490778b81835d28f297135796befec74a3ca5f6f6d5b3204f65a0f6686d58875df53e1332d96b6ef09edbac
7
- data.tar.gz: 0fec1b06196dc2fecd95464694ae1d9742fb72687ac676b5a6def977b1a965a2f137b70edb85310f273237d8a7f6370aaa6a193d5c926487e30710d53de720f0
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` (supported in ActiveRecord 5.2+)
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.
@@ -40,10 +40,11 @@ ActiveSupport.on_load(:active_record) do
40
40
  PgParty::Hacks::SchemaCache
41
41
  )
42
42
 
43
- require "pg_party/hacks/database_tasks"
43
+ require "active_record/tasks/postgresql_database_tasks"
44
+ require "pg_party/hacks/postgresql_database_tasks"
44
45
 
45
- ActiveRecord::Tasks::DatabaseTasks.extend(
46
- PgParty::Hacks::DatabaseTasks
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgParty
4
- VERSION = "1.2.0"
4
+ VERSION = "1.2.1"
5
5
  end
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.0
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-27 00:00:00.000000000 Z
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/database_tasks.rb
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