pg_partitioner 0.7.1 → 0.8.2

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: c0da4dec1e40244392b6e9a4ea8697f6be6c799cdcdb21d953c5960a95a90d13
4
- data.tar.gz: 9f0ca569ccf89d535e52519a8939e80f5b350210b8b5223fe8a5d24fe5dc99e3
3
+ metadata.gz: 9c728338fd4206174f0dc4f4632c7dd54be951f419295f56c96d0b161327ced9
4
+ data.tar.gz: bca15bd396a5606b632e8c3f00af80163bd6d6a8f65d3626e1e7ea7761338575
5
5
  SHA512:
6
- metadata.gz: 4359bec7e42a91eb246eb0c9674b1a19f77fbf23de2db309720c5373904f3c4cf6511f4aaf622654d87355535e7f93db69c12cc26987623cbfed6dc56477ebf0
7
- data.tar.gz: 307a1258bc48b6fda905543c2501de5b6fcc931fb41270e476bcf6ec4ab30b43dcdb352aa55a53aa929abd073b35844e20ef3d80cc42d0e173fd31afef17836a
6
+ metadata.gz: 6d1d47e0c1e8bf3d70b2c4f1de6702cedb1a337025bbbd22d14e8c6a783a3167c19a8fc14462cd25793feee5fb91a7e0c4117959c54188ee4b24ec33871793e9
7
+ data.tar.gz: fe83006a1699ef8cb31ce9dc2e1fe739bb1c220cf1a93223a339648b6662d144993ce7b7ce4a317409f66a6f4765cbae21958b2335af138076695771bb5aa01f
data/README.md CHANGED
@@ -115,3 +115,9 @@ or
115
115
  ```ruby
116
116
  YourModel.create_next_quater_table
117
117
  ```
118
+
119
+ 4) You can get all partition table names for your model:
120
+
121
+ ```ruby
122
+ YourModel.partition_table_names
123
+ ```
@@ -73,6 +73,17 @@ module PgPartitioner
73
73
  end
74
74
  end
75
75
  end
76
+
77
+ def partition_table_names
78
+ sql = "SELECT child.relname
79
+ FROM pg_inherits
80
+ JOIN pg_class parent ON pg_inherits.inhparent = parent.oid
81
+ JOIN pg_class child ON pg_inherits.inhrelid = child.oid
82
+ WHERE parent.relname = '#{table_name}'
83
+ ORDER BY child.relname;"
84
+
85
+ execute_sql(sql).map { |row| row['relname'] }
86
+ end
76
87
  end
77
88
  end
78
89
  end
@@ -1,12 +1,12 @@
1
1
  module PgPartitioner
2
2
  module SeparationType
3
3
  module Month
4
- def create_current_month_table
5
- create_month_table(Date.today)
4
+ def create_current_month_table(autovacuum:)
5
+ create_month_table(Date.today, autovacuum:)
6
6
  end
7
7
 
8
- def create_next_month_table
9
- create_month_table(Date.today.next_month)
8
+ def create_next_month_table(autovacuum:)
9
+ create_month_table(Date.today.next_month, autovacuum)
10
10
  end
11
11
 
12
12
  def drop_old_month_table
@@ -15,7 +15,7 @@ module PgPartitioner
15
15
  drop_table(table_name)
16
16
  end
17
17
 
18
- def create_month_table(date = Date.today)
18
+ def create_month_table(date = Date.today, autovacuum = true)
19
19
  date_start = date.at_beginning_of_month
20
20
  date_end = date.at_beginning_of_month.next_month
21
21
  partition_table_name = name_of_partition_table(date, type: :month)
@@ -28,7 +28,7 @@ module PgPartitioner
28
28
  sql = "ALTER TABLE #{partition_table_name} ADD PRIMARY KEY (id);"
29
29
  execute_sql(sql)
30
30
 
31
- disable_autovacuum(partition_table_name)
31
+ disable_autovacuum(partition_table_name) if autovacuum == false
32
32
  create_partition_indexes(partition_table_name)
33
33
  create_partition_named_indexes(partition_table_name)
34
34
  create_partition_unique_indexes(partition_table_name)
@@ -1,15 +1,15 @@
1
1
  module PgPartitioner
2
2
  module SeparationType
3
3
  module Quater
4
- def create_current_quater_table
5
- create_quater_table(Date.today)
4
+ def create_current_quater_table(autovacuum:)
5
+ create_quater_table(Date.today, autovacuum)
6
6
  end
7
7
 
8
- def create_next_quater_table
9
- create_quater_table(Date.today.next_quarter)
8
+ def create_next_quater_table(autovacuum:)
9
+ create_quater_table(Date.today.next_quarter, autovacuum)
10
10
  end
11
11
 
12
- def create_quater_table(date = Date.today)
12
+ def create_quater_table(date = Date.today, autovacuum = true)
13
13
  date_start = date.at_beginning_of_quarter
14
14
  date_end = date.end_of_quarter.next_month.at_beginning_of_month
15
15
  partition_table_name = name_of_partition_table(date, type: :quater)
@@ -22,7 +22,7 @@ module PgPartitioner
22
22
  sql = "ALTER TABLE #{partition_table_name} ADD PRIMARY KEY (id);"
23
23
  execute_sql(sql)
24
24
 
25
- disable_autovacuum(partition_table_name)
25
+ disable_autovacuum(partition_table_name) if autovacuum == false
26
26
  create_partition_indexes(partition_table_name)
27
27
  create_partition_named_indexes(partition_table_name)
28
28
  create_partition_unique_indexes(partition_table_name)
@@ -1,12 +1,12 @@
1
1
  module PgPartitioner
2
2
  module SeparationType
3
3
  module Week
4
- def create_current_week_table
5
- create_week_table(Date.today)
4
+ def create_current_week_table(autovacuum: )
5
+ create_week_table(Date.today, autovacuum)
6
6
  end
7
7
 
8
- def create_next_week_table
9
- create_week_table(Date.today.next_week)
8
+ def create_next_week_table(autovacuum: )
9
+ create_week_table(Date.today.next_week, autovacuum)
10
10
  end
11
11
 
12
12
  def drop_old_week_table
@@ -15,7 +15,7 @@ module PgPartitioner
15
15
  drop_table(table_name)
16
16
  end
17
17
 
18
- def create_week_table(date = Date.today)
18
+ def create_week_table(date = Date.today, autovacuum = true)
19
19
  date_start = date.at_beginning_of_week
20
20
  date_end = date.at_beginning_of_week.next_week
21
21
  partition_table_name = name_of_partition_table(date, type: :week)
@@ -28,7 +28,7 @@ module PgPartitioner
28
28
  sql = "ALTER TABLE #{partition_table_name} ADD PRIMARY KEY (id);"
29
29
  execute_sql(sql)
30
30
 
31
- disable_autovacuum(partition_table_name)
31
+ disable_autovacuum(partition_table_name) if autovacuum == false
32
32
  create_partition_indexes(partition_table_name)
33
33
  create_partition_named_indexes(partition_table_name)
34
34
  create_partition_unique_indexes(partition_table_name)
@@ -1,3 +1,3 @@
1
1
  module PartitionerPg
2
- VERSION = '0.7.1'
2
+ VERSION = '0.8.2'
3
3
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_partitioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ovsapyan Mishel
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-10-22 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: bundler
@@ -61,6 +62,7 @@ homepage: http://appodeal.com
61
62
  licenses: []
62
63
  metadata:
63
64
  allowed_push_host: https://rubygems.org
65
+ post_install_message:
64
66
  rdoc_options: []
65
67
  require_paths:
66
68
  - lib
@@ -75,7 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
77
  - !ruby/object:Gem::Version
76
78
  version: '0'
77
79
  requirements: []
78
- rubygems_version: 3.7.1
80
+ rubygems_version: 3.5.11
81
+ signing_key:
79
82
  specification_version: 4
80
83
  summary: Gem for a partitoning PG tables
81
84
  test_files: []