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 +4 -4
- data/README.md +10 -0
- data/lib/pg_partitioner/separation_type/base.rb +13 -5
- data/lib/pg_partitioner/version.rb +1 -1
- data/lib/pg_partitioner.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5cfb29fd8934e56c5ede73e05b301f5fe56f638addfe8c8173475bc07fb54dcd
|
|
4
|
+
data.tar.gz: b0a9bb4f7183283fb979026ffb0f56478f2b17574efb4050fe502ca2d78ef59c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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.
|
|
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
|
|
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.
|
|
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
|
|
data/lib/pg_partitioner.rb
CHANGED
|
@@ -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,
|
|
41
|
-
connection.add_index
|
|
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,
|
|
45
|
-
connection.add_index
|
|
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.
|
|
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:
|
|
11
|
+
date: 2026-04-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|