pg_partitioner 0.6.0 → 0.7.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: 50f0688a4db1ff7d246b9d1256aec91e7c08e764c75091bd638d50afca53d36f
4
- data.tar.gz: 55e882b5e908e23800512707d55ba692490a93871cc510df62ea558c241f8a58
3
+ metadata.gz: 5cfb29fd8934e56c5ede73e05b301f5fe56f638addfe8c8173475bc07fb54dcd
4
+ data.tar.gz: b0a9bb4f7183283fb979026ffb0f56478f2b17574efb4050fe502ca2d78ef59c
5
5
  SHA512:
6
- metadata.gz: 8f61dbf0fa33a97b5bff0783cf91545163673c53efdb5cce35c9f18a3431d9bfee0c69e0bd48e125992456488aa7358c59878d2916a3aae9db030efd6e443b1e
7
- data.tar.gz: 2db636b574c655f4d6b223602cab4f11c45719a685cf901b1a5523a668b02bd7f26cfd9cff76cada02a4b231fc3df5be8b4be3ed5f14ba62be0a9b4c76b22738
6
+ metadata.gz: 2c541e52f227979b2dfc958f200d6dccb3bafec5fec4d96d6e0e48ccc75b31af385fea2897302d1a116a84025a093fb3f8c8a481df8334f3a1ba2eea65114122
7
+ data.tar.gz: 15086b751b086d43bff24cd7f4a01c7e5b1dfcb3f81370cdc81cd6d84dd2930e3e27e31ccae73d468c17b95abca58934394efe7293e6f321c451c1b27217cbf6
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,20 @@ 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
+ create_custom_index(partition_table_name, custom_index[:fields], **custom_index.except(:fields))
25
+ else
26
+ create_custom_index(partition_table_name, custom_index)
27
+ end
28
+ end
23
29
  end
24
30
 
25
31
  def create_partition_named_indexes(partition_table_name)
26
32
  custom_indexes = partition_table_named_indexes.presence
27
33
  return unless custom_indexes
28
34
 
29
- custom_indexes.map do |name, custom_index|
35
+ custom_indexes.each do |name, custom_index|
30
36
  index_name = "index_#{partition_table_name}_#{name}"
31
37
  create_custom_named_index(partition_table_name, custom_index, index_name)
32
38
  end
@@ -36,16 +42,18 @@ module PgPartitioner
36
42
  custom_unique_indexes = partition_table_unique_indexes.presence
37
43
  return unless custom_unique_indexes
38
44
 
39
- custom_unique_indexes.each { |custom_index| create_custom_index(partition_table_name, custom_index, true) }
45
+ custom_unique_indexes.each do |custom_index|
46
+ create_custom_index(partition_table_name, custom_index, unique: true)
47
+ end
40
48
  end
41
49
 
42
50
  def create_partition_named_unique_indexes(partition_table_name)
43
51
  custom_indexes = partition_table_named_unique_indexes.presence
44
52
  return unless custom_indexes
45
53
 
46
- custom_indexes.map do |name, custom_index|
54
+ custom_indexes.each do |name, custom_index|
47
55
  index_name = "index_#{partition_table_name}_#{name}"
48
- create_custom_named_index(partition_table_name, custom_index, index_name, true)
56
+ create_custom_named_index(partition_table_name, custom_index, index_name, unique: true)
49
57
  end
50
58
  end
51
59
 
@@ -1,3 +1,3 @@
1
1
  module PartitionerPg
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
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,14 @@
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ovsapyan Mishel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-18 00:00:00.000000000 Z
11
+ date: 2026-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler