pg_partitioner 0.6.0 → 0.7.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: 50f0688a4db1ff7d246b9d1256aec91e7c08e764c75091bd638d50afca53d36f
4
- data.tar.gz: 55e882b5e908e23800512707d55ba692490a93871cc510df62ea558c241f8a58
3
+ metadata.gz: c0da4dec1e40244392b6e9a4ea8697f6be6c799cdcdb21d953c5960a95a90d13
4
+ data.tar.gz: 9f0ca569ccf89d535e52519a8939e80f5b350210b8b5223fe8a5d24fe5dc99e3
5
5
  SHA512:
6
- metadata.gz: 8f61dbf0fa33a97b5bff0783cf91545163673c53efdb5cce35c9f18a3431d9bfee0c69e0bd48e125992456488aa7358c59878d2916a3aae9db030efd6e443b1e
7
- data.tar.gz: 2db636b574c655f4d6b223602cab4f11c45719a685cf901b1a5523a668b02bd7f26cfd9cff76cada02a4b231fc3df5be8b4be3ed5f14ba62be0a9b4c76b22738
6
+ metadata.gz: 4359bec7e42a91eb246eb0c9674b1a19f77fbf23de2db309720c5373904f3c4cf6511f4aaf622654d87355535e7f93db69c12cc26987623cbfed6dc56477ebf0
7
+ data.tar.gz: 307a1258bc48b6fda905543c2501de5b6fcc931fb41270e476bcf6ec4ab30b43dcdb352aa55a53aa929abd073b35844e20ef3d80cc42d0e173fd31afef17836a
data/README.md CHANGED
@@ -53,6 +53,16 @@ class YourModelName < ActiveRecord::Base
53
53
  end
54
54
  end
55
55
  ```
56
+ Alternative usage of `partition_table_indexes` method. You can pass additional params to index creation with this way:
57
+ ```ruby
58
+ def self.partition_table_indexes
59
+ [
60
+ { fields: %w(column1 column2) },
61
+ { fields: %w(column1 column2 column3), name: 'my_index_for_column1_column2', unique: true },
62
+ { fields: %w(column1), where: 'user_id IS NOT NULL' }
63
+ ]
64
+ end
65
+ ```
56
66
  2) Create migration and add some instructions to it. Generate migration:
57
67
 
58
68
  ```
@@ -19,14 +19,22 @@ module PgPartitioner
19
19
  custom_indexes = partition_table_indexes.presence
20
20
  return unless custom_indexes
21
21
 
22
- custom_indexes.each { |custom_index| create_custom_index(partition_table_name, custom_index) }
22
+ custom_indexes.each do |custom_index|
23
+ if custom_index.is_a?(Hash)
24
+ name = custom_index[:name]
25
+ custom_index[:name] = "index_#{partition_table_name}_#{name}" if name
26
+ create_custom_index(partition_table_name, custom_index[:fields], **custom_index.except(:fields))
27
+ else
28
+ create_custom_index(partition_table_name, custom_index)
29
+ end
30
+ end
23
31
  end
24
32
 
25
33
  def create_partition_named_indexes(partition_table_name)
26
34
  custom_indexes = partition_table_named_indexes.presence
27
35
  return unless custom_indexes
28
36
 
29
- custom_indexes.map do |name, custom_index|
37
+ custom_indexes.each do |name, custom_index|
30
38
  index_name = "index_#{partition_table_name}_#{name}"
31
39
  create_custom_named_index(partition_table_name, custom_index, index_name)
32
40
  end
@@ -36,16 +44,18 @@ module PgPartitioner
36
44
  custom_unique_indexes = partition_table_unique_indexes.presence
37
45
  return unless custom_unique_indexes
38
46
 
39
- custom_unique_indexes.each { |custom_index| create_custom_index(partition_table_name, custom_index, true) }
47
+ custom_unique_indexes.each do |custom_index|
48
+ create_custom_index(partition_table_name, custom_index, unique: true)
49
+ end
40
50
  end
41
51
 
42
52
  def create_partition_named_unique_indexes(partition_table_name)
43
53
  custom_indexes = partition_table_named_unique_indexes.presence
44
54
  return unless custom_indexes
45
55
 
46
- custom_indexes.map do |name, custom_index|
56
+ custom_indexes.each do |name, custom_index|
47
57
  index_name = "index_#{partition_table_name}_#{name}"
48
- create_custom_named_index(partition_table_name, custom_index, index_name, true)
58
+ create_custom_named_index(partition_table_name, custom_index, index_name, unique: true)
49
59
  end
50
60
  end
51
61
 
@@ -1,3 +1,3 @@
1
1
  module PartitionerPg
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.1'
3
3
  end
@@ -37,12 +37,12 @@ module PgPartitioner
37
37
  connection.execute(sql_string)
38
38
  end
39
39
 
40
- def create_custom_index(table_name, index_fields, is_unique = false)
41
- connection.add_index table_name, index_fields, unique: is_unique
40
+ def create_custom_index(table_name, index_fields, **keys)
41
+ connection.add_index(table_name, index_fields, **keys)
42
42
  end
43
43
 
44
- def create_custom_named_index(table_name, index_fields, name, is_unique = false)
45
- connection.add_index table_name, index_fields, name: name, unique: is_unique
44
+ def create_custom_named_index(table_name, index_fields, name, **keys)
45
+ connection.add_index(table_name, index_fields, name: name, **keys)
46
46
  end
47
47
 
48
48
  def disable_autovacuum(table_name)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_partitioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ovsapyan Mishel
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -62,7 +61,6 @@ homepage: http://appodeal.com
62
61
  licenses: []
63
62
  metadata:
64
63
  allowed_push_host: https://rubygems.org
65
- post_install_message:
66
64
  rdoc_options: []
67
65
  require_paths:
68
66
  - lib
@@ -77,8 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
75
  - !ruby/object:Gem::Version
78
76
  version: '0'
79
77
  requirements: []
80
- rubygems_version: 3.5.11
81
- signing_key:
78
+ rubygems_version: 3.7.1
82
79
  specification_version: 4
83
80
  summary: Gem for a partitoning PG tables
84
81
  test_files: []